0
Trying to figure out how to add a loop to a program for class
I've got some if/elif statements to determine what age group a person would fall into(you'll see in the code below) I need to make a loop that continues the "age evaluation" while the user wants to continue the loop I know how to setup while loops in general, but I'm struggling to add it into this specific code for whatever reason. https://code.sololearn.com/c4IwOD1paoUE/?ref=app
7 Réponses
+ 2
So it has to be the IDE ! :)
+ 1
Do you mean that the user has to make several inputs ?
Then maybe you should ask the user for a list of ages as an input ?
+ 1
Diego Acero
I've tried that and get an EOF Error...
Seems to be complicated to ask for several inputs.
0
The user needs to input whether they'd like to continue the loop or not, and input the age in question, so yes multiple inputs.
0
while True:
# If user inputs 0 the program ends
# You can choose any value
if x == 0:
break
# Rest of the code goes here
0
Delorme Try this as input (separate lines):
1
12
18
30
0
Or use and IDE that supports multiple inputs.
0
Found a solution, I set a variable (in my case b) equal to one, started a while loop where the condition was b ==1, and prompt the user at the end to continue or not, if no b would be set to 0 to end the loop
https://code.sololearn.com/c4IwOD1paoUE/?ref=app