A ZeroDivisionError
occurs if you try to divide a number with 0.
A ZeroDivisionError
is a type of ArithmeticError
.
print(10 / 0)
Try it Yourself » Definition and UsageThe ArithmeticError
exception is the base exception for the three arithmetic error excpetions:
FloatingPointError
OverflowError
ZeroDivisionError
You can handle the ArithmeticError
in a try...except
statement, see the example below.
Handling the ArithmeticError
in a try...except
statement:
try:
print(10 / 0)
except ArithmeticError:
print("Error in calculation")
except:
print("Something else went wrong")
Track your progress - it's free!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4