I am writing a choose-your-own-adventure style game in python (terminal based) and I would like the program to pause printing until the enter
button is pressed. Here is an example.
print("zzzzzzzzz")
the press enter to continue would come here. Then, after they press enter, this block would run.
print("yyyyyy")
Python 3 is preferable.
In Python 3 use input(): input("Press Enter to continue...") In Python 2 use raw_input(): raw_input("Press Enter to continue...")
You could use a simple while loop: line = "Y" while line[0] not in ("n", "N"): """ game here """ line = input("Play again (Y/N)?")
1: press "Enter" to continue. 2: press "Esc" to exit the program.
If you've got a Python program and you want to make it wait, you can use a simple function like this one: time. sleep(x) where x is the number of seconds that you want your program to wait.
Python 2:
raw_input("Press Enter to continue...")
Python 3:
input("Press Enter to continue...")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With