itertools.count() in Python

PHOTO EMBED

Tue Jun 18 2024 02:25:51 GMT+0000 (Coordinated Universal Time)

Saved by @pynerds #python

#itertools.count()- creates an iterator which yields infinite sequence of integers from a starting point 

from itertools import count

seq = count(0, 2) #an infinite sequence of even numbers

print(next(seq))
print(next(seq))
print(next(seq))
print(next(seq))
print(next(seq))
content_copyCOPY

https://www.pynerds.com/python-itertools-count/