Help with String Manipulation

Greg Ewing greg.ewing at
Wed Jun 23 23:35:16 EDT 1999

Or, if you'd like something a bit more creative:

def gnirts(s):
    n = len(s)
    if n < 2:
        return s
        return gnirts(s[n/2:]) + gnirts(s[:n/2])

print gnirts("a")
print gnirts("ab")
print gnirts("abc")
print gnirts("abcd")
print gnirts("It's not dead, it's just... resting!")

(Hmmm... the output from that last test case looks
a bit like Klingon...)


More information about the Python-list mailing list