Reputation: 35
I have a python script that is using
while:
try:
except:
I am wondering how to stop it running (not exit script) and then return to the beginning.
Upvotes: 1
Views: 40
Reputation: 35
I think I have this now. when using except, just call the main function again.
Upvotes: 0
Reputation:
Just wrap it with another loop, and add some conditions to avoid infinite loop.
is_done = False
while is_done:
while your_condition:
try:
# Your task
is_done = True
break
except Exception as e:
print(e)
break
Upvotes: 1