A function adds results to a list that it is given. Part way through, one of the results fails, and the caller handles the error.
def fill(target, values):
for v in values:
target.append(10 // v)
return len(target)
data = []
try:
n = fill(data, [5, 2, 0, 1])
except ZeroDivisionError:
n = -1
print(n, data)
What does the program print?