def main():
# Put all your code in here
def restart():
main()
exit()
main()
Then anytime you need your code to restart, just call restart (Note that variables will not be saved between loops, and if you do this too many times the code will crash due to a recursion limit.)