Reverse


#1


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

I am getting an Error which says "Oops, try again. Your function fails on reverse("Python!"). It returns " !nohtyP" when it should return "!nohtyP".

Unless I am missing something obvious the code and the response should work. Any help is appreciated.


def reverse(text):
    length = len(text)
    reverse_string = " "
    while length >= 1:
        reverse_string = reverse_string + text[length-1]
        length = length -1
    return reverse_string


#2

It returns

" !nohtyP"

when it should return

"!nohtyP"

see the difference. there is space before ! .

consider where does it come from?


#3

thank you very much. I addressed the problem and you saved me @rcodeman


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.