when I used this code:

def reverse(text):
total = len(text) - 1
word = ""
for i in text:
word += text[total]
total -= 1
print word


it gives an error which says: Your function fails on reverse(“Python!”). It returns “None” when it should return “!nohtyP”.

I clicked back and tried this code in there and result was ‘!nohtyP’ as intended. So why cannot I use this here?


None is default returned by function, the exercise state we should return the function should return the reversed string, which isn’t happening, given the default (None) is returned


thank you for reply… I tried return and it worked…


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