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


It returns

" !nohtyP"

when it should return


see the difference. there is space before ! .

consider where does it come from?


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


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