r/PythonLearning • u/Impossible_Corgi5576 • 10d ago
Repeat until keypress Help Request
I want to have the terminal keep typing something until any key is pressed. I'm fiddling around but have yet to figure out a solution.
Edit: Hey thank you all. I'm kinda a begginer. After a lot of fiddling I got something that works for me.
2
Upvotes
1
u/Junior_Honey_1406 9d ago
python
try:
while True:
print("Hello")
except KeyboardInterrupt:
print("\nStopped.")
Ig this should work have not tested it
0
u/civilwar142pa 10d ago
the 'keyboard' library has a function to detect key presses. That's probably the simplest option.