[Tutor] Working with strings

Gregor Lingl glingl@mail.rg16.asn-wien.ac.at
Mon, 12 Mar 2001 19:40:10 +0100


Concerning the problem: reversing a string

I think, since
   print x,
inserts a space after printing x, it
is better first to construct the backword
and then return it to a print-statement:

For instance:

>>> def backword(s):
        s = list(s)
        s.reverse()
        return ''.join(s)

>>> print backword("abraham")
maharba
>>>

Have fun!
Gregor