ZeroDivisionError

Built-in ExceptionPython 2.0+Beginner

Raised when dividing or modding by zero

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# Triggering and catching ZeroDivisionError
try:
    result = 1 / 0
except ZeroDivisionError as e:
    print(f"Caught ZeroDivisionError: {e}")
    print(f"Type: {type(e).__name__}")

ZeroDivisionError is raised when raised when dividing or modding by zero. Always catch specific exceptions rather than bare except clauses.

Try in Playground

Tags

exceptionerror-handlingcore