diff options
author | Raymond Hettinger <python@rcn.com> | 2011-06-25 13:00:46 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2011-06-25 13:00:46 (GMT) |
commit | 04e1012e2ddc6a00c2d589b66bb3b80ef074eebb (patch) | |
tree | 0d95da9658eb2b6bf019df1f0298c900bc496e60 /Doc | |
parent | 36a9de041ba4af3e6df011f8f577fd75b25002eb (diff) | |
parent | 9d3df6d5080539c7c1ab792fdf9784fe3c30af5f (diff) | |
download | cpython-04e1012e2ddc6a00c2d589b66bb3b80ef074eebb.zip cpython-04e1012e2ddc6a00c2d589b66bb3b80ef074eebb.tar.gz cpython-04e1012e2ddc6a00c2d589b66bb3b80ef074eebb.tar.bz2 |
Issue 11889: Clarify docs for enumerate.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/functions.rst | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 1c1c167..b766a2e 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -331,14 +331,13 @@ are always available. They are listed here in alphabetical order. :term:`iterator`, or some other object which supports iteration. The :meth:`__next__` method of the iterator returned by :func:`enumerate` returns a tuple containing a count (from *start* which defaults to 0) and the - corresponding value obtained from iterating over *iterable*. - - >>> for i, season in enumerate('Spring Summer Fall Winter'.split(), start=1): - print(i, season) - 1 Spring - 2 Summer - 3 Fall - 4 Winter + values obtained from iterating over *iterable*. + + >>> seasons = ['Spring', 'Summer', 'Fall', 'Winter'] + >>> list(enumerate(seasons)) + [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')] + >>> list(enumerate(seasons, start=1)) + [(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')] Equivalent to:: |