A function returns a result after a try statement that has all four blocks. Three of the blocks print a word.
def ratio(a, b):
try:
r = a / b
except ZeroDivisionError:
print("zero", end=" ")
r = 0
else:
print("ok", end=" ")
finally:
print("end", end=" ")
return r
print(ratio(6, 3), ratio(1, 0))
What is printed on the screen?
Log in to join the discussion.
Loading…