By itertools.count, we can easily create count up generateor.
def count_up(start, stop, step): cnt = itertools.count(start, step) for i in cnt: if i > stop: break: else: yield i print list(count_up(1, 10, 2)) >>[1, 3, 5, 7, 9]
By itertools.count, we can easily create count up generateor.
def count_up(start, stop, step): cnt = itertools.count(start, step) for i in cnt: if i > stop: break: else: yield i print list(count_up(1, 10, 2)) >>[1, 3, 5, 7, 9]