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

Paul Rubin http
Fri Oct 20 01:34:46 CEST 2006

Steven D'Aprano <steve at> 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