In Python

January 23, 2019 Critical Thinking

In Python, error handling is done through the use of syntax errors or exceptions. An exception is an error that occurs while the program is being executed. This means that the syntax of the code is correct, but an error still occurred. When this happens, Python will generate an exception, which crashes the program if unhandled. These can be caught in try ‘blocks’ of code and handled in ‘except’ blocks. When the error is encountered, the try code is stopped and the except block is executed. This prevents the code from crashing so that it can continue running. For example, if a string that is not made up of numbers has the computer try to convert it to an integer, the program will crash but if a try: except: is in place, the code will continue to run

x

Hi!
I'm Casey!

Would you like to get a custom essay? How about receiving a customized one?

Check it out