Calico: ZeroDivisionError

From IPRE Wiki
Jump to: navigation, search

A ZeroDivisionError occurs when you attempt to divide by zero. In most programming languages dividing by zero is not allowed. If you try, then this error will occur. ZeroDivisionError is a specific Calico: RuntimeError error---it occurs when you run a program. There are other kinds of errors, for example, when you attempt to load a script.

You can usually avoid the error by checking that the denominator is not zero. For example:

if denominator != 0:
    result = numerator / denominator
    print("Cannot divide by zero")

If denominator is zero, then you should stop at that point and not continue any further.

Index to other pages describing errors: