7. Reverse - remove quotations


#1

My code does reverse the string, but it puts individual letters into the list with quotation marks around them. I think removing them might have been part of an earlier lesson, but I can't seem to find it. Putting str() around last doesn't fix the problem.

def reverse(text):
`gth=len(text)
backwards=[]
while gth>0:
last=text[gth-1]
backwards.append(last)
gth-=1
return backwards'

gives me the error: Oops, try again. Your function fails on reverse("Python!"). It returns "['!', 'n', 'o', 'h', 't', 'y', 'P']" when it should return "!nohtyP".
in terms of formatting, everything is one tab in other than the definition, and everything under while and above return is another tab in.


#2

you need to join all the elements in the list by doing

return "".join(backwards)

#3

this worked for me..(properly indented though)

def reverse(text):
lst = list(text)
i=0
j=len(lst)-1
while i temp=lst[i]
lst[i]=lst[j]
lst[j]=temp
i+=1
j-=1
return "".join(lst)