16 lines
307 B
Python
16 lines
307 B
Python
# exceptions/multiple.py
|
|
values = (1, 2) # try (1, 0) and ('one', 2)
|
|
|
|
try:
|
|
q, r = divmod(*values)
|
|
except (ZeroDivisionError, TypeError) as e:
|
|
print(type(e), e)
|
|
|
|
|
|
try:
|
|
q, r = divmod(*values)
|
|
except ZeroDivisionError:
|
|
print("You tried to divide by zero!")
|
|
except TypeError as e:
|
|
print(e)
|