Composition of functions

Zubin Mithra zubin.mithra at gmail.com
Thu Jul 1 00:09:52 EDT 2010


Hello,

>>> y=list(x).reverse()
> >>> print y
> None
>

>>> L = ["a", "b", "c"]
>>> L.reverse()
>>> L
["c", "b", "a"]

As you can see, L.reverse() performs the operation on itself and returns
nothing. Hence, the return type None.

Instead of

y=''.join(list(x).reverse())

you should probably do,

>>> t = list(x).reverse()
>>> y = ''.join(t)

Cheers!
Zubin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100701/7eac035d/attachment-0001.html>


More information about the Python-list mailing list