Reverse function python? How to use?
Kay Schluehr
kay.schluehr at gmx.net
Mon Oct 30 03:20:39 EST 2006
frankie_85 wrote:
> Ok I'm really lost (I'm new to python) how to use the reverse function.
>
>
> I made a little program which basically the a, b, c, d, e which I have
> listed below and basically I want it th result to be printed reverse so
> instead doing "print e, d, c, b, a", I'd like to use the reverse
> function
You can use extended slice operators
http://www.python.org/doc/2.3.5/whatsnew/section-slices.html [1]
This function call should do what yo expect
print [e, d, c, b, a][::-1]
[1] Does anyone know where to find a comprehensible description of
enhanced slices in the Python docs besides an an aged "What's new?"
column? Or is it intended that newbies read this
http://docs.python.org/ref/slicings.html ?
More information about the Python-list
mailing list