7. Reverse



Error: Your function fails on reverse("Python!"). It returns "!" when it should return "!nohtyP".

Apparently, I can get the last of the string printed, but for some reason I cannot get it to loop.

def reverse(text):
    rev = ''
    length = len(text)
    for i in range(length):
        rev += text[length-1]
        return rev
        length -= 1
    print rev

Any ideas?


replace print by return , and remove return rev