# Reverse

#1

Hi iam suprised about the function returns cba!nohtyP instead of !nohtyP. I dont have any idea where the cba comes from.I write the code in Pycharm and in Pycharm the function return the correct solution.
Can you explain me why the function writes cba in front of the solution string.

Your function fails on reverse("Python!"). It returns "cba!nohtyP" when it should return "!nohtyP".

It should return !nohtyP

`python

value=[]
def reverse(text):
total= len(text)-1
for n in text:
value.append(text[total])
total=total-1
solution=""
for n in value:
solution=solution+str(n)
return solution

#2

the exercise calls the function multiply times, to test your function works correctly

so everything you need for reversing should be inside the function

#3

Thank you for your answer. But actually everthin is inside the function. Below you can see the fuction with the indented code.

``````value=[]
def reverse(text):
total= len(text)-1
for n in text:
value.append(text[total])
total=total-1
solution=""
for n in value:
solution=solution+str(n)
return solution

print reverse("Python!")``````

`

#4

``value=[]``

^ not inside the function? so calling the function multiply times means the list won't be emptied

#7

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