0
Please what can I do to make the program as for another input after the first one has been inputed.
print("menu") print("Enter records") print("see statistics") print("List all records") print("Quit") print("..........................") x = int(input()) if x == 1: print("Enter records") elif x ==2: print("See statistics") elif x ==3: print("List all records") elif x == 4: print("Quit")..... I know it's a loop but I dunno how or where to write it so it can ask for another input so the user can select...pls help this is in python thanks
5 Answers
+ 1
You need a while loop. Basically, you need to keep asking for x until the user enters Quit, so you can do something like this:
While True:
x = int(input())
If x == 'Quit':
break
You can put the rest of your code below that.
0
Ok so pls show me an e.g using my code above
0
Well, you can start the while loop either right above all of your code to print the menu options after each iteration or you can start it right before asking for x so you can ask the user to input on each iteration but not printing the menu options every time
0
Great you understand.
Now my problem is how do I write it
What position do I put the while loop
0
David Solomon Put the while loop before the part of the code you want to loop. (e.g.
while True:
(Tab) input("? ")
)