

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: Errors and Exceptions in Python
incomplete
2: Try/Except Review
incomplete
3: Raising Your Own Exceptions
incomplete
4: Raising Exceptions Review
incomplete
5: Different Types of Exceptions
incomplete
6: Raising Exceptions Review
incomplete
7: Raising Exceptions Review
incomplete
8: Raising Exceptions Review
incomplete
9: Purchase Bug
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
As you've noticed, there are many types of exceptions. Many specific exceptions are built into the language like IndexError and ZeroDivisionError, and (almost) all Exceptions count as the parent Exception type. except matches exceptions by type, not by the message string passed to Exception(...). It catches the named type and more specific types, but not more general ones.
If you're interested in the official documentation on all the built-in exceptions you can find a list here.
try:
raise Exception("zero division")
except ZeroDivisionError as e:
print("zero")