String reverse


#1

'''
def reverse(text):
rtext=[]
for i in range(len(text)-1,0,-1):
rtext.append()=text[i]
return rtext
'''
What's wrong in this code.It shows error message
File "python", line 4
SyntaxError: can't assign to function call


#2

Hey,
First off,

rtext = []

should be

rtext = ""

.
next:
instead of:

range(len(text)-1, 0, -1)

type:

range(len(text)-1, -1, -1)

.
and lastly,
instead of:

rtext.append() = text[i]

it should be:

rtext += text[i]

Hope this helps :slightly_smiling:


#3

Yes,it worked and I understood my problem in code.
Thanks a lot.:slightly_smiling:


#4

Could you elaborate on this line? I understand the 1st -1, but after that I get a little confused....thanks!