From dc62aeca4cd13ead75adece6a99089457087e687 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 7 Nov 2003 01:30:58 +0000 Subject: [PATCH] Add a new looping idiom --- Doc/tut/tut.tex | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index e6017b07b2..508a7aef0f 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}} -- 2.50.1