invert or reverse a string... warning this is a rant

Paul Rubin http
Thu Oct 19 19:34:46 EDT 2006


Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
> >>> ''.join(list(reversed("some string")))
> 'gnirts emos'

''.join(reversed('some string')) should work, without building the
intermediate list.

I generally don't remember the ::-1 syntax so the above would occur to
me sooner.



More information about the Python-list mailing list