New submission from Trey Hunner <>:

>From the itertools documentation: 

> Also, used with zip() to add sequence numbers.

I'm not certain what the goal of the original sentence was, but I think it's 
unclear as currently written.

I assume this is what's meant:

my_sequence = [1, 2, 3, 4]
for i, item in zip(count(1), my_sequence):
    print(i, item)

This is a strange thing to note though because enumerate would be a better use 

my_sequence = [1, 2, 3, 4]
for i, item in enumerate(my_sequence, start=1):
    print(i, item)

Maybe what is meant is that count can be used with a step while enumerate 

my_sequence = [1, 2, 3, 4]
for i, item in zip(count(step=5), my_sequence):
    print(i, item)

If that's the case it seems like step should instead be mentioned there instead 
of "sequence numbers".

assignee: docs@python
components: Documentation
messages: 313606
nosy: docs@python, trey
priority: normal
severity: normal
status: open
title: itertools.count() confusingly mentions zip() and sequence numbers
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

Python tracker <>
Python-bugs-list mailing list

Reply via email to