So, as the title says, I want a proper code to close my python script.
So far, I\'ve used input(\'Press Any Key To Exit\')
, but what that does, is generate a er
a = input('Press a key to exit')
if a:
exit(0)
Ok I am on Linux Mint 17.1 "Rebecca" and I seem to have figured it out, As you may know Linux Mint comes with Python installed, you cannot update it nor can you install another version on top of it. I've found out that the python that comes preinstalled in Linux Mint is version 2.7.6, so the following will for sure work on version 2.7.6. If you add raw_input('Press any key to exit')
it will not display any error codes but it will tell you that the program exited with code 0. For example this is my first program. MyFirstProgram. Keep in mind it is my first program and I know that it sucks but it is a good example of how to use "Press any key to Exit"
BTW This is also my first post on this website so sorry if I formatted it wrong.
If you are on windows then the cmd pause
command should work, although it reads 'press any key to continue'
import os
os.system('pause')
The linux alternative is read
, a good description can be found here