A ZeroDivisionError
occurs if you try to divide a number with 0:
print(10 / 0)
Try it Yourself » Definition and UsageThe ZeroDivisionError
exception occurs when you try to devide a number with 0, and when you perform a modulo operation with 0.
The ZeroDivisionError
exception is one of three ArithmeticError
You can handle the ZeroDivisionError
in a try...except
statement, see the example below.
A ZeroDivisionError
occurs if you try to perform a modulo operation with 0:
Handling the ZeroDivisionError
in a try...except
statement:
try:
print(10 / 0)
except ZeroDivisionError:
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