diff options
author | Raymond Hettinger <python@rcn.com> | 2012-04-23 21:24:15 -0700 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2012-04-23 21:24:15 -0700 |
commit | 4c8d392bc1424a186fa8230e56200676c4f5e754 (patch) | |
tree | 510117eadc0d23cfd52846571a0da73a53ce7e39 | |
parent | 016878aea6fb1904b8a04c7f56223c90cd8a0522 (diff) | |
download | cpython-git-4c8d392bc1424a186fa8230e56200676c4f5e754.tar.gz |
Reorder the entries to put the type specific technique last.
-rw-r--r-- | Doc/tutorial/datastructures.rst | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 489a336a83..0240e616b7 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -577,16 +577,6 @@ keyword arguments:: Looping Techniques ================== -When looping through dictionaries, the key and corresponding value can be -retrieved at the same time using the :meth:`iteritems` method. :: - - >>> knights = {'gallahad': 'the pure', 'robin': 'the brave'} - >>> for k, v in knights.iteritems(): - ... print k, v - ... - gallahad the pure - robin the brave - When looping through a sequence, the position index and corresponding value can be retrieved at the same time using the :func:`enumerate` function. :: @@ -633,6 +623,16 @@ returns a new sorted list while leaving the source unaltered. :: orange pear +When looping through dictionaries, the key and corresponding value can be +retrieved at the same time using the :meth:`iteritems` method. :: + + >>> knights = {'gallahad': 'the pure', 'robin': 'the brave'} + >>> for k, v in knights.iteritems(): + ... print k, v + ... + gallahad the pure + robin the brave + .. _tut-conditions: |