def func(a, b):
try:
print(a / b)
except ZeroDivisionError as e:
print('Exception Error:', e)
else:
print('finish')
#normal
func(1, 2)
#Exception error because it does not break at 0
func(1, 0)
0.5
finish
Exception Error: division by zero
Recommended Posts