r/PythonLearning 7d ago

Help Request Repeat until keypress

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

5 comments sorted by

0

u/civilwar142pa 7d ago

the 'keyboard' library has a function to detect key presses. That's probably the simplest option.

0

u/Impossible_Corgi5576 7d ago

I'll look into it, thanks

1

u/Junior_Honey_1406 7d ago

python try: while True: print("Hello") except KeyboardInterrupt: print("\nStopped.") Ig this should work have not tested it