Correct way to pause a Python program
So, I found this to work very well in my coding endeavors. I simply created a function at the very beginning of my program,
def pause(): programPause = raw_input("Press the <ENTER> key to continue...")
and now I can use the pause()
function whenever I need to just as if I was writing a batch file. For example, in a program such as this:
import osimport systemdef pause(): programPause = raw_input("Press the <ENTER> key to continue...")print("Think about what you ate for dinner last night...")pause()
Now obviously this program has no objective and is just for example purposes, but you can understand precisely what I mean.
NOTE: For Python 3, you will need to use input
as opposed to raw_input