Iteration Classes

itertools.count()

Produce an unbounded arithmetic progression. Bound consumption with islice or a loop; floating steps can accumulate rounding error.

Formal Syntax & Structure

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

Parameters & Attributes

NameTypeDescription
startint or numberStarting position or value.
stepint or numberIncrement or stride.

Return Value

iterator

The iterator result described above.

Working Example

Example Snippetpython
import itertoolsprint(list(itertools.islice(itertools.count(3,2),4)))
Python Reference