summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/tutorial')
-rw-r--r--Doc/tutorial/controlflow.rst8
1 files changed, 6 insertions, 2 deletions
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index 2a55cf1..000d9cb 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -113,8 +113,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)):
@@ -126,6 +126,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`.
+
A strange thing happens if you just print a range::
>>> print(range(10))
@@ -148,6 +151,7 @@ is another; it creates lists from iterables::
Later we will see more functions that return iterables and take iterables as argument.
+
.. _tut-break:
:keyword:`break` and :keyword:`continue` Statements, and :keyword:`else` Clauses on Loops