I want to make a Python program that will ask the user for a restart or end the program itself. I googled a bit to get an idea for this type of execution and gather some pieces of information. After researching a bit understand, I need to import the OS module from the library. How can I proceed further? Could you please help me in this regard? I am expecting your answers. Thanks.
Well, as far as you are asking for a self-restart program, you can try the below program:
result = input("\nDo you want to restart the program? [y/n] > ")
if result == 'y':
print("\nThe program will be closed...")
This will print an Output of “Hello World!” and then ask the user for the confirmation to proceed on or not! Pressing the ‘Y’ yes will execute the path file from the desired folder else the program will be closed immediately. Please, have a close look at the above program and let me know if you still have any confusion.
Thanks and good luck!