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

Fredrik Lundh fredrik at pythonware.com
Thu Oct 19 12:25:26 EDT 2006


rick wrote:

> The Ruby approach makes sense to me as a human being.

do the humans on your planet spend a lot of time reversing strings? 
it's definitely not a very common thing to do over here.

anyway, if you do this a lot, why not define a helper function?

     def reverse(s):
         return s[::-1]

     print reverse("redael ruoy ot em ekat")

</F>




More information about the Python-list mailing list