Python closes after running script

broken image
broken image

Notice how the exit text appears at the end of the output no matter where we place theĪll was made, rather than where the code exits. Type your name, and when you hit enter you should get: What's your name? Open the input.py file again and replace the text with this import atexitĪtexit.register(print,'Program exited successfully!') To experiment with atexit, let’s modify our input.py example to print a message at the program exit. Handles anything we want the program to do when it exits and is typically used to do program clean up before the program process terminates