It works but won't go through


Why does this give me the error: Oops, try again. Your function fails on reverse("Python!"). It returns "Python!" when it should return "!nohtyP".

it works when it is run.

def reverse(text):

    while i>=0:
        print text[i],
    return text



It may be printing correctly, but it is returning the original inputs, so will never pass. Rather than print, try building a new string and return that.

result = ""
while i >= 0:
    result += text[i]
    i -= 1
return result