Prevention


We might try to prevent the exceptions generated by the system, but even if succeed in preventing it, how do we indicate that there was an issue? For example with the input?

examples/exceptions/preventing_divide_by_zero.py
def div(a, b):
    if b == 0:
        # raise Exception("Cannot divide by zero")
        print("Cannot divide by zero")
        return None

    print("before")
    print(a/b)
    print("after")

div(1, 0)