0

I would like to restart my python code from the beginning after a given "yes" input from the user, but I can't understand what I'm doing wrong here:

if input("Other questions? ") == 'yes' or 'yeah':
    main()
else:
    pass

my code is included within the function main(). Thanks for the help!!

1 Answers1

2

You would probably do it with a while loop around the whole thing you want repeated, and as Loic RW said in the comments, just break out of the while loop:

while True:
    # do whatever you want

    # at the end, you ask your question:
    if input("Other questions? ") in ['yes','yeah']:
        # this will loop around again
        pass
    else:
        # this will break out of the while loop
        break
kamion
  • 469
  • 2
  • 9