I am trying to not stop the program when the user press Ctrl + C.
Now it's like this:
(programm running)
...
(user press ctrl+c)
You pressed ctrl+c
breaks
What I want is:
(programm running)
...
(user press ctrl+c)
You pressed ctrl+c
not breaks
How can I do this? Is it impossible?
I tried this code:
try:
while True:
userinput = input()
if userinput == "stop":
break
except (KeyboardInterrupt, SystemExit):
print('You pressed ctrl+c')
I tried adding pass
to except
, but It doesn't give the expected output.