diff options
author | Raymond Hettinger <python@rcn.com> | 2003-11-07 01:30:58 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-11-07 01:30:58 (GMT) |
commit | dc62aeca4cd13ead75adece6a99089457087e687 (patch) | |
tree | 303febb7dd578a526b2936deb492bc128e316556 | |
parent | 5ce2fecf8edfcb1c8210f1a3da83e0cef7b1fa50 (diff) | |
download | cpython-dc62aeca4cd13ead75adece6a99089457087e687.zip cpython-dc62aeca4cd13ead75adece6a99089457087e687.tar.gz cpython-dc62aeca4cd13ead75adece6a99089457087e687.tar.bz2 |
Add a new looping idiom
-rw-r--r-- | Doc/tut/tut.tex | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index e6017b0..508a7ae 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -2162,6 +2162,21 @@ What is your quest? It is the holy grail. What is your favorite color? It is blue. \end{verbatim} +To loop over a sequence in reverse, first specify the sequence +in a forward direction and then call the \function{reversed()} +function. + +\begin{verbatim} +>>> for i in reversed(xrange(1,10,2)): +... print i +... +9 +7 +5 +3 +1 +\end{verbatim} + \section{More on Conditions \label{conditions}} |