Generators - counter
examples/generators/generator_counter.py
def counter(): n = 1 while True: yield n n += 1 for c in counter(): print(c) if c >= 10: break
1 2 3 4 5 6 7 8 9 10
def counter(): n = 1 while True: yield n n += 1 for c in counter(): print(c) if c >= 10: break
1 2 3 4 5 6 7 8 9 10