

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. What differentiates exceptions are their types, not their string descriptions. This is important to know when handling errors from imported modules.
If you're interested in the official documentation on all the built-in exceptions you can find a list here.
This code is simply raising an Exception with the text "zero division".
try:
raise Exception("zero division")
except ZeroDivisionError as e:
print("zero")
except Exception as e:
print("other")