def createCounter():
x = []
def counter():
x.append(1)
return sum(x)
return counter
def createCounter2():
x = 0
nonlocal x
x += 1
return x
Sign in to make a reply
B O O M!
def createCounter():
x = []
def counter():
x.append(1)
return sum(x)
return counter
def createCounter2():
x = 0
def counter():
nonlocal x
x += 1
return x
return counter