invert the order of a string

Paul Rubin http
Mon Feb 13 19:05:07 EST 2006


rtilley <rtilley at vt.edu> writes:
> s = list('some_random_string')
> print s
> s.reverse()
> print s
> s = ''.join(s)
> print s
> 
> Surely there's a better way to do this, right?

In Python 2.4, just say
  s = reversed('some_random_string')



More information about the Python-list mailing list