Composition of functions
MRAB
python at mrabarnett.plus.com
Thu Jul 1 11:29:31 EDT 2010
Zubin Mithra wrote:
>
> Er, I don't think you thought that one entirely through (/ tried it
> out):
>
>
> My Apologies.
>
> Here is a working one.
>
> >>> x="123"
> >>> t = list(x)
> >>> t.reverse()
> >>> print ''.join(t)
> 321
>
>
> But of course, the method which was suggested earlier is far more elegant.
>
> >>> print ''.join(reversed(list(x)))
>
If you want even more elegance, try slicing:
>>> x = "123"
>>> print x[ : : -1]
321
More information about the Python-list
mailing list