Reverse


#1

when I used this code:

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

reverse(‘Python!’)

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?


#2

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


#3

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


#4

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