A loop prints a value in a try block. One item is the text "2", and only one kind of error is handled.
for v in [4, 0, "2", 5]:
try:
print(100 // v, end=" ")
except ZeroDivisionError:
print("inf", end=" ")
print("end")
What happens when the program runs?
Log in to join the discussion.
Loading…