Everytime I press CTRL-C when I am running a program it displays what line it was executing and then says:
Keyboard Interrupt
However, I am running a program that appends info to text files. It someone presses CTRL-C during that it would only only append what the code got to do before it was interrupted.
I heard of try and except
but does that work if I call it at the beggining and someone presses CTRL C during the try phase?
How do I make it so that if anytime in the program someone presses CTRL-C it will not run the program, revert everything it did so far and say:
Exiting Program