[Tutor] reversing a string
pythonTutor at venix.com
Sat Oct 9 02:38:56 CEST 2004
On Fri, 2004-10-08 at 20:31, Rich Krauter wrote:
> Kirk Bailey wrote:
> > ok, something struck a spark in my concrete enshrouded skull; how does
> > one reverse a string.
> > Consider a string:'qwerty'. A SIMPLE and FAST process to reverse it. I
> > considered appending and recursion, but there ought to be a better way,
> > although dealing off the bottom of the deck does have a peverse
> > attraction to it (slicing and taking -1 char off the string and
> > appending it to a string).
> > Anyone want to discuss this task?
> This works in 2.3:
> >>> 'qwerty'[-1::-1]
Or the slightly simpler to type:
> Tutor maillist - Tutor at python.org
More information about the Tutor