On Wed, Jun 30, 2010 at 9:09 PM, Zubin Mithra <zubin.mit...@gmail.com> wrote: > 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)
Er, I don't think you thought that one entirely through (/ tried it out): ch...@morpheus ~ $ python Python 2.6.5 (r265:79063, May 25 2010, 18:21:57) [GCC 4.2.1 (Apple Inc. build 5659)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = "hello" >>> t = list(x).reverse() >>> print t None >>> ''.join(t) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list