# code to perform any specific tasks to catch that exception How does KeyboardInterrupt Exception work in Python?
# raising this exception is not mandatory To catch the exception and perform desired tasks, special code inside the except block is written. Code which can cause the error is placed inside the try block with the ‘raise’ keyword to raise that exception or the python interpreter automatically raises it. There is no such specific syntax of KeyboardInterrupt exception in Python, it is handled in the normal try and except block inside the code. Web development, programming languages, Software testing & othersĪs seen above, KeyboardInterrupt exception is a normal exception which is thrown to handle the keyboard related issues.
Start Your Free Software Development Course