Skip to content

Instantly share code, notes, and snippets.

@JAChapmanII
Created April 25, 2014 22:43
Show Gist options
  • Save JAChapmanII/11305634 to your computer and use it in GitHub Desktop.
Save JAChapmanII/11305634 to your computer and use it in GitHub Desktop.
generators in python
def fibonacci():
a, b = 1, 1
while True:
yield a
a, b = a + b, a
x = 0
for f in fibonacci():
print(f)
x += 1
if x > 10:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment