In [1]:
def divide(a, b):
print(a / b)
In [2]:
# divide(1, 0)
# ZeroDivisionError: division by zero
In [3]:
def divide_exception(a, b):
try:
print(a / b)
except ZeroDivisionError as e:
print('ZeroDivisionError: ', e)
In [4]:
divide_exception(1, 0)
In [5]:
def divide_exception_pass(a, b):
try:
print(a / b)
except ZeroDivisionError as e:
pass
In [6]:
divide_exception_pass(1, 0)