100 is shared between a number of people. The helper counts each failure and then passes the error on with a bare raise.
failures = 0
def share(total, people):
global failures
try:
return total / people
except ZeroDivisionError:
failures += 1
raise
for people in (2, 0, 5, 0):
try:
share(100, people)
except ArithmeticError:
failures += 10
print(failures)
What does the program print?Log in to join the discussion.
Loading…