Created
February 1, 2017 00:04
-
-
Save kissgyorgy/92e477507ebfd126d90ee38438e3550a to your computer and use it in GitHub Desktop.
Python: hack instead of nonlocal keyword in Python2
This file contains hidden or 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 fibonacci(): | |
a, b = [1], [0] | |
def fibo(): | |
a[0], b[0] = b[0], a[0] + b[0] | |
return a[0] | |
return fibo | |
fib = fibonacci() | |
for _ in range(10): | |
print fib(), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment