Skip to content

Instantly share code, notes, and snippets.

@edenau edenau/
Last active Dec 27, 2019

What would you like to do?
Python Generator
def gen(n): # an infinite sequence generator that generates integers >= n
while True:
yield n
n += 1
G = gen(3) # starts at 3
print(next(G)) # 3
print(next(G)) # 4
print(next(G)) # 5
print(next(G)) # 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.