Python: Reverse Function Works Sometimes

The problem is that for code academy to accept your code, you have to return the reversed function, not just print it. Your code might look something like this (notice the difference):

def reverse(text):
    returnValue = ""
    l = len(text)-1
    for t in text:
        returnValue = returnValue + text[l]
        l-=1
    return returnValue

then,

print reverse("Python!")

will print:

!nohtyP

Leave a Comment