@@ -4286,7 +4286,7 @@ \section{Exceptions Are Classes Too\label{exceptionClasses}}
42864286\section {Iterators\label {iterators } }
42874287
42884288By now, you've probably noticed that most container objects can be looped
4289- over using a \code {for} statement:
4289+ over using a \keyword {for} statement:
42904290
42914291\begin {verbatim }
42924292for element in [1, 2, 3]:
@@ -4302,11 +4302,12 @@ \section{Iterators\label{iterators}}
43024302\end {verbatim }
43034303
43044304This style of access is clear, concise, and convenient. The use of iterators
4305- pervades and unifies Python. Behind the scenes, the \code {for} statement calls
4306- \function {iter()} on the container object. The function returns an iterator
4307- object that defines the method \method {next()} which accesses elements in the
4308- container one at a time. When there are no more elements, \method {next()}
4309- raises a \exception {StopIteration} exception which tells the \code {for} loop
4305+ pervades and unifies Python. Behind the scenes, the \keyword {for}
4306+ statement calls \function {iter()} on the container object. The
4307+ function returns an iterator object that defines the method
4308+ \method {next()} which accesses elements in the container one at a
4309+ time. When there are no more elements, \method {next()} raises a
4310+ \exception {StopIteration} exception which tells the \keyword {for} loop
43104311to terminate. This example shows how it all works:
43114312
43124313\begin {verbatim }
0 commit comments