It works but won't go through


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/1/1?curriculum_id=4f89dab3d788890003000096


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):
    i=len(text)-1

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


reverse("Python!")


#2

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