I am working on Python 2.7 on windows.
How to close the program by keyboard interrupt in python.
I made some code but it asks me every time to give a input and then perform something according to that. I want that the code should not ask me every time and at any random time when I give the input it should perform the corresponding action (for my case close the program)
while 1:
var = raw_input("enter a to stop: ")
if var == 'a':
break
exit()