Python - itertools.count()


Python tip:

You can use count from itertools to make an iterator that returns evenly spaced values:

itertools.count(start=0, step=1)

For example, to generate all odd numbers greater or equal to 101👇

from itertools import count

odd_numbers = count(101, 2)

# first ten elements
for _ in range(10):
    print(next(odd_numbers))

"""
101
103
105
107
109
111
113
115
117
119
"""