How to guarantee desired results in python?

assert help us to guarantee that our code will have the desired results.
def division(numl: int, num2: int): 
    assert num2!= 0, "num2 must be different from 0"
    return numl/num2
print(division(2, 0))

Result:

AssertionError: num2 must be different from 0

Leave a Reply