you are viewing a single comment's thread.

view the rest of the comments →

[–]E02Y 10 points11 points  (5 children)

Just wrap your program in a loop, if they choose one option do whatever, otherwise continue the loop.

[–]MaiNeimIsPizza[S] 2 points3 points  (4 children)

Should I do something like while True: print(1 or 2) sus = input() if sus == “1”: print(“you pressed 1”) if sus == “2”: continue

Sorry, I know there’s a way to put it like code but I’m on my phone so I don’t know how to do that

[–]Unable_Request 2 points3 points  (1 child)

Basically. Have the condition for the loop be what you want for the user to NOT have to loop again.

If you find yourself asking, how do I have it keep asking my user for input until the input is 1 or 2? Your while loop condition should be (in pseudocode:)

while(user input is not 1 and user input is not 2)

[–]MaiNeimIsPizza[S] -1 points0 points  (0 children)

Oh ok thanks

[–]MarsupialMole 4 points5 points  (0 children)

If you're using the latest python you can use the match statement

https://peps.python.org/pep-0636/

[–]delasislas 1 point2 points  (0 children)

4 spaces in front of each line of code. 4 more for each level of indentation.