Can you provide an example of a `ZeroDivisionError` in Python?

Question

Grade: Education Subject: Support
Can you provide an example of a `ZeroDivisionError` in Python?
Asked by:
62 Viewed 62 Answers

Answer (62)

Best Answer
(278)
A `ZeroDivisionError` is a classic runtime error. It occurs when you attempt to divide a number by zero. For example: ```python result = 10 / 0 # This will raise a ZeroDivisionError print(result) ``` The program will halt execution and display a traceback indicating the error.