Quiz · Functions as values · lesson 6 of 10
Quiz — a closure counter
What does the program print?
def make_counter():
count = 0
def counter():
nonlocal count
count += 1
return count
return counter
c = make_counter()
print(c(), c(), make_counter()())Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.