0

How do I keep on asking for an input when a loop doesn't accept it through conditional?

https://code.sololearn.com/cgkSBW6776eF/?ref=app My professors says using another loop inside a loop will cause the program to be slower. Is there any way to keep asking for an input when they entered greater than 100 and still be on the same loop without iteration? For example, if it's the first loop, x=0 and they entered 101, it should stay at x=0 but will ask an input again. I hope that's clear. Thank you!

3rd Feb 2020, 8:23 AM
Gerald Macasaet
Gerald Macasaet - avatar
4 Answers
+ 1
you're itterating with x right ? just modify the value of x so it'll same after the increment in the next iteration.
3rd Feb 2020, 8:44 AM
Taste
Taste - avatar
+ 2
Try including x-- inside the else.
3rd Feb 2020, 8:43 AM
Avinesh
Avinesh - avatar
0
Avinesh Good Thought! Thanks. I'll try.
3rd Feb 2020, 8:43 AM
Gerald Macasaet
Gerald Macasaet - avatar
0
Taste and Avinesh How about of there is a two needed input? I revamped the code. When I enter a wrong input, it goes back to the prior loop, how do I attack it now so it goes on the same loop and not go back?
3rd Feb 2020, 9:49 AM
Gerald Macasaet
Gerald Macasaet - avatar