Минимальный воспроизводимый пример
Код: Выделить всё
def make_counter():
count = 0
def inc(step=1):
if step > 0:
count += step
return count
return inc
c = make_counter()
print(c())
Код: Выделить всё
UnboundLocalError: local variable 'count' referenced before assignment
Подробнее здесь: https://stackoverflow.com/questions/798 ... ion-closur
Мобильная версия