Reverse a String?
Leif K-Brooks
eurleif at ecritters.biz
Sat Sep 23 17:04:57 EDT 2006
Gregory Piñero wrote:
> Is my mind playing tricks on me? I really remember being able to
> reverse a string as in:
>
> text='greg'
> print text.reverse()
>>> 'gerg'
That method has never existed AFAIK. Maybe you're thinking of the
reverse() method on lists?
In any case, the you can reverse strings in a couple of ways:
>>> ''.join(reversed('foo'))
'oof'
>>> 'foo'[::-1]
'oof'
More information about the Python-list
mailing list