""" generator.py a demo of python generator $ python generator.py 0 1 2 3 4 """ def count_to_n(n): i = 0 while True: if i < n: yield i i = i + 1 else: return for i in count_to_n(5): print(i)