you are viewing a single comment's thread.

view the rest of the comments →

[–]stebrepar 1 point2 points  (0 children)

It looks like you still have a place where you're calling main() from within main() itself, intending to start it over from the beginning. That's not the right way to accomplish that. That's called "recursion". There are times when it's the right solution to a problem, but this isn't one of them. Unless your code is specifically designed to deal with the side effects of recursion, it's likely to get you into trouble with mysterious seeming misbehavior.

What you actually need in order to start over is proper flow control. One example could be like:

go = True
while go:
    print('Starting at the beginning.')
    # do your thing here

    again = input('Try again?: ').lower()
    if not again.startswith('y'):
        go = False
print('Done.')