Created
August 28, 2020 18:39
-
-
Save tekknolagi/1719a18b728bc1fab7e9ea7e88e6efc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gen(): | |
counter = 0 | |
def get(): | |
return counter | |
def inc(): | |
nonlocal counter | |
counter += 1 | |
return counter | |
return get, inc | |
for i in range(10): | |
get, inc = gen() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment