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