Handling Exceptions In Python
Few examples of Exceptions
10 * (1/0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
4 + spam*3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'spam' is not defined
'2' + 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Can't convert 'int' object to str implicitly1. Handling Exceptions
2. The else Block
3. Analyzing Text (using try-except)
4. Failing Silently
Last updated