@@ -139,18 +139,24 @@ but in fact it isn't. It is an object which returns the successive items of
139139the desired sequence when you iterate over it, but it doesn't really make
140140the list, thus saving space.
141141
142- We say such an object is * iterable * , that is, suitable as a target for
142+ We say such an object is :term: ` iterable ` , that is, suitable as a target for
143143functions and constructs that expect something from which they can
144- obtain successive items until the supply is exhausted. We have seen that
145- the :keyword: `for ` statement is such an * iterator *. The function :func: ` list `
146- is another; it creates lists from iterables ::
144+ obtain successive items until the supply is exhausted. We have seen that
145+ the :keyword: `for ` statement is such a construct, while an example of function
146+ that takes an iterable is :func: ` sum ` ::
147147
148+ >>> sum(range(4)) # 0 + 1 + 2 + 3
149+ 6
148150
149- >>> list(range(5))
150- [0, 1, 2, 3, 4]
151+ Later we will see more functions that return iterables and take iterables as
152+ arguments. Lastly, maybe you are curious about how to get a list from a range.
153+ Here is the solution::
151154
152- Later we will see more functions that return iterables and take iterables as argument.
155+ >>> list(range(4))
156+ [0, 1, 2, 3]
153157
158+ In chapter :ref: `tut-structures `, we will discuss in more detail about
159+ :func: `list `.
154160
155161.. _tut-break :
156162
@@ -161,7 +167,7 @@ The :keyword:`break` statement, like in C, breaks out of the innermost enclosing
161167:keyword: `for ` or :keyword: `while ` loop.
162168
163169Loop statements may have an :keyword: `!else ` clause; it is executed when the loop
164- terminates through exhaustion of the list (with :keyword: `for `) or when the
170+ terminates through exhaustion of the iterable (with :keyword: `for `) or when the
165171condition becomes false (with :keyword: `while `), but not when the loop is
166172terminated by a :keyword: `break ` statement. This is exemplified by the
167173following loop, which searches for prime numbers::
@@ -188,8 +194,8 @@ following loop, which searches for prime numbers::
188194the :keyword: `for ` loop, **not ** the :keyword: `if ` statement.)
189195
190196When used with a loop, the ``else `` clause has more in common with the
191- ``else `` clause of a :keyword: `try ` statement than it does that of
192- :keyword: `if ` statements: a :keyword: `! try ` statement's ``else `` clause runs
197+ ``else `` clause of a :keyword: `try ` statement than it does with that of
198+ :keyword: `if ` statements: a :keyword: `try ` statement's ``else `` clause runs
193199when no exception occurs, and a loop's ``else `` clause runs when no ``break ``
194200occurs. For more on the :keyword: `!try ` statement and exceptions, see
195201:ref: `tut-handling `.
0 commit comments