diff options
author | Raymond Hettinger <python@rcn.com> | 2011-06-25 12:57:06 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2011-06-25 12:57:06 (GMT) |
commit | 320b91495ad758578cbfc5124ec9e07978eebc19 (patch) | |
tree | 6647058b9d479128975d11660ff8e1b54def9959 /Doc | |
parent | 67a3e8336fdfed67b7734871c88fe7f6fc334117 (diff) | |
download | cpython-320b91495ad758578cbfc5124ec9e07978eebc19.zip cpython-320b91495ad758578cbfc5124ec9e07978eebc19.tar.gz cpython-320b91495ad758578cbfc5124ec9e07978eebc19.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 57748b6..1c4793f 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -341,14 +341,13 @@ 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 *sequence*:: - - >>> 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 *sequence*:: + + >>> 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:: |