Error: reverse("Python!") fails --> returns "!nohtyP" not "!nohtyP"


This is the error message:
Oops, try again. Your function fails on reverse(“Python!”). It returns " !nohtyP" when it should return “!nohtyP”.

The error message appears to tell me that the function DOES work while also claiming it does not work. Am I hallucinating? I’ve already tried refreshing the page, clearing browser cache and starting again, what am I missing here? Thanks!


def reverse(text):
a = " "
i = len(text)
while i:
a += text[i]
return a



see the space between " and !? Its the cause of the problem:


i replaced the space with a underscore so you can see it.

The problem seems to be a isn’t an empty string when you define it


Thank you so much! I knew it had to be something tiny like that that I just wasn’t seeing! It’s like in other languages when someone is sure he has all his semi-colons but then a fresh set of eyes spots a missing one. Thanks.