1 2 3 4 5 6 7 8 9 10
def make_counter(start=0): def inc(step=1): nonlocal start start += step return start return inc c = make_counter(10) print(c()) # 11 print(c(5)) # 16