-3

Basically, I have a "raw_input" then an "if" statement and then many "elif" statements after it. If the user inputs invalid data I want the "else" to print a string, then restart the program so the user can try again. How can I do this?

martineau
  • 119,623
  • 25
  • 170
  • 301
Jakewade09
  • 23
  • 6

1 Answers1

1

Put your code in a loop:

while True:
    # Code here

To exit the loop, use break, which will also quit the program.

while True:
    # Code here
    if running == False:    # The condition for breaking is up to you, if you're using one
        break
Anthony Pham
  • 3,096
  • 5
  • 29
  • 38