1import os
2import sys
3
4restart = input("\nDo you want to restart the program? [y/n] > ")
5
6if restart == "y":
7 os.execl(sys.executable, os.path.abspath(__file__), *sys.argv)
8else:
9 print("\nThe program will be closed...")
10 sys.exit(0)
11
1import os
2import sys
3
4if(input("Would you like to restart?\n") == "y"):
5 os.execl(sys.executable, 'python', '"{}"'.format(__file__), *sys.argv[1:])
6else:
7 exit(0)