Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Stopping code while the input line is running

$
0
0

I'm trying to write super simple code where I take input and print it.

userInput = input('enter: ')print(userInput)

The problem that I'm having is when I'm stopping code while the input line is running, I'm getting a error:

Traceback (most recent call last):  File "C:\Users\97258\PycharmProjects\pythonProject6\tast.py", line 1, in <module>    input('enter: ')  File "<frozen codecs>", line 319, in decodeKeyboardInterrupt

I was given a task to somehow make the code not to crash.

I tried adding the try and catch function but it didn't help, probably because the code stops before the catch can catch it.

I'm only expecting the code to not give me an error and finish with exit code 0 or -1 when I stop the code.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>