Reverse


#1

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

When length = 0, I get this error: Oops, try again. Your code looks a bit off–it threw a “string index out of range” error. Check the Hint if you need help!
When I changed length to 1, I got this: Oops, try again. Your function fails on reverse(“Python!”). It returns “!nohty” when it should return “!nohtyP”.

Now if the “P” is cut off when I use 1, but 0 is out of range… these messages seem to contradict.

def reverse(text):
    final = ""
    length = 1
    while length < len(str(text)):
        final += text[len(str(text)) - length]
        length += 1
    return final

#2

your loop ends to early, it skips the last character, you should change the loop condition


#3

Did it. Thank you!!!


#4