blob: 41a727545c3ce954443c15e73e886fdeec63abf4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
def divide_x_by_y(x: float, y: float):
try:
print(x / y)
except FloatingPointError as e:
print(f"There was a FloatingPointError: {e}")
except ArithmeticError as e:
# FloatingPointError were already caught at this point
print(f"There was an OverflowError or a ZeroDivisionError: {e}")
# Or:
def divide_x_by_y(x: float, y: float):
try:
print(x / y)
except ArithmeticError as e:
print(f"There was an OverflowError, a ZeroDivisionError or a FloatingPointError: {e}")
|