0

I am unsure why my program behaves how it does when I input words where it should receive numbers. I'm using try and except.

My code runs as expected when I input propper inputs but when I input words where it should be numbers it starts to behave weirdly. It should call main and ask for user input again when the try except fails. It seems to instead ask for the same input multiple times or input it shouldn't ask for. https://code.sololearn.com/c8dKcgQW8TE6/?ref=app

8th May 2019, 5:11 AM
Elijah
2 Respuestas
+ 5
Replace every main() with return main(). Otherwise, it'll call the main function again but still try to use the invalid values after that. return main() will actually interrupt the main function and start from the beginning (I hope this explanation makes sense)
8th May 2019, 5:19 AM
Anna
Anna - avatar
0
It makes perfect sense. I can't say I exactly understand the why of it but I understand it trying to rerun with bad values again.
8th May 2019, 5:26 AM
Elijah