>> I am playing with Python. Playing as in learning. >> Is it possible to reverse a range sequence? If, for instance, I >> call: >> >> for f in range( 1,5 ): >> print f >> >> Is it possible to reverse it? As in: >> 4 >> 3 >> 2 >> 1
>Yes, there is a normally unused third parameter to range used to control the step size. It can bew negative so: >range(4,0,-1) And then there is also this reversed() call: >>> for f in reversed(range(1,5)): print f 4 3 2 1 >>> Thanks, Senthil _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor