A loop adds a note to a list before a statement that can fail. Two except blocks add other notes.
log = []
for v in ["3", "0", "x", "5"]:
try:
log.append("in")
log.append(12 // int(v))
except ZeroDivisionError:
log.append("Z")
except ValueError:
log.append("V")
print(log)
What does the program print?
Log in to join the discussion.
Loading…