7. Reverse


#1




I get this error message: Oops, try again. Your function fails on reverse("Python!"). It returns " !nohtyP" when it should return "!nohtyP".
Where am I wrong?


isn't those two strings the same?


def reverse(text):
    resp = " "
    for i in range(len(text)-1, -1, -1):
        resp += text[i]
    return resp


#2

I have the same problem too, maybe a bug?


#3

I already find the error, redefining resp = "" at line 2 fixed it.


#4

resp = " " gives a space that won't get the exact result


#5

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