From: Georg Brandl Date: Thu, 4 Dec 2008 18:54:05 +0000 (+0000) Subject: Add reference to enumerate() to indices example. X-Git-Tag: v2.7a1~2592 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34196c851a92cfcde12532673f5d073e5ee6d6a3;p=thirdparty%2FPython%2Fcpython.git Add reference to enumerate() to indices example. --- diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 809afc146e9b..f57e9e9780ad 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -104,8 +104,8 @@ increment (even negative; sometimes this is called the 'step'):: >>> range(-10, -100, -30) [-10, -40, -70] -To iterate over the indices of a sequence, combine :func:`range` and :func:`len` -as follows:: +To iterate over the indices of a sequence, you can combine :func:`range` and +:func:`len` as follows:: >>> a = ['Mary', 'had', 'a', 'little', 'lamb'] >>> for i in range(len(a)): @@ -117,6 +117,9 @@ as follows:: 3 little 4 lamb +In most such cases, however, it is convenient to use the :func:`enumerate` +function, see :ref:`tut-loopidioms`. + .. _tut-break: