What is ZeroDivisionError?

A ZeroDivisionError in Python occurs when we try to divide a number by 0. We can’t divide a number by 0 otherwise it will raise an error. Let us understand it with the help of an example. In this example, we are dividing a number from 0 and we can see that it raises a ZeroDivisionError.

Python3

a=20
b=0
print(a/b)

ZeroDivisionError: float division by zero in Python

In this article, we will see what is ZeroDivisionError and also different ways to fix this error.

Similar Reads

What is ZeroDivisionError?

A ZeroDivisionError in Python occurs when we try to divide a number by 0. We can’t divide a number by 0 otherwise it will raise an error. Let us understand it with the help of an example. In this example, we are dividing a number from 0 and we can see that it raises a ZeroDivisionError....

Contact Us