This function should make a counter. The program should print 11 12, but it stops with UnboundLocalError.
def make_counter(start):
def step():
start += 1
return start
return step
c = make_counter(10)
print(c(), c())
Which one change makes it print 11 12?
Log in to join the discussion.
Loading…