diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index c397ed4f218b6a..74323a2ba245f4 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -201,9 +201,10 @@ iteration of the loop:: :keyword:`!else` Clauses on Loops ================================= -In a :keyword:`!for` or :keyword:`!while` loop the :keyword:`!break` statement -may be paired with an :keyword:`!else` clause. If the loop finishes without -executing the :keyword:`!break`, the :keyword:`!else` clause executes. +A :keyword:`!for` or :keyword:`!while` loop may be paired with an +:keyword:`!else` clause, often with a :keyword:`break` inside the loop. +If the loop finishes without executing the :keyword:`!break`, the +:keyword:`!else` clause executes. In a :keyword:`for` loop, the :keyword:`!else` clause is executed after the loop finishes its final iteration, that is, if no break occurred. @@ -240,16 +241,16 @@ which searches for prime numbers:: the ``for`` loop, **not** the ``if`` statement.) One way to think of the else clause is to imagine it paired with the ``if`` -inside the loop. As the loop executes, it will run a sequence like -if/if/if/else. The ``if`` is inside the loop, encountered a number of times. If +inside the loop. The ``if`` is inside the loop, encountered a number of times. If the condition is ever true, a ``break`` will happen. If the condition is never true, the ``else`` clause outside the loop will execute. -When used with a loop, the ``else`` clause has more in common with the ``else`` -clause of a :keyword:`try` statement than it does with that of ``if`` -statements: a ``try`` statement's ``else`` clause runs when no exception -occurs, and a loop's ``else`` clause runs when no ``break`` occurs. For more on -the ``try`` statement and exceptions, see :ref:`tut-handling`. +The :keyword:`!else` clause of a :keyword:`!for` loop can also be understood +similarly to the :keyword:`!else` clause of a :keyword:`try` statement: a +:keyword:`!try` statement's :keyword:`!else` clause runs when no exception +occurs, and a :keyword:`!for` loop's :keyword:`!else` clause runs when no +:keyword:`!break` occurs. For more on the :keyword:`!try` statement and +exceptions, see :ref:`tut-handling`. .. index:: single: ...; ellipsis literal .. _tut-pass: