change KeyboardInterrupt to 'enter'
change KeyboardInterrupt to 'enter' Question: I have the following code: import time def run_indefinitely(): while True: # code to run indefinitely goes here print("Running indefinitely…") time.sleep(1) try: # Run the code indefinitely until Enter key is pressed run_indefinitely() except KeyboardInterrupt: print("Loop interrupted by user") Is there a way to break out of the while loop …