more newbie help needed

Fredrik Lundh fredrik at pythonware.com
Mon Nov 14 16:45:03 EST 2005


Craig Marshall wrote:

> Or, if you're *really* just trying to reverse the string, then the
> following might read more easily (although it's probably longer):

> fruit = list(fruit)
> fruit.reverse()
> fruit = ''.join(fruit)

same thing, on one line:

    fruit = "".join(reversed(fruit))

same thing, in one operation:

    fruit = fruit[::-1]

</F>






More information about the Python-list mailing list