7.reverse


#1

What's wrong with this code?

def reverse(text):
lengthoftext = len(text)
lengthoftext -= 1
textlist = list(text)
stuff = []
for n in range(lengthoftext,-1,-1):
stuff.append(textlist[n])
answer = ''.join(stuff)
print '"' + answer + '"'
reverse("Python!")


#2

It isn't indented.

Yeah it might be indented in your version of the code, but why then are you showing me THIS?

Also I have no clue what to look for, explain how it behaves and how you expect it to behave.

Be specific, explain what you need to solve it yourself. (As opposed to dumping the (broken) code and hoping that somebody will do the job for you)


#3

Dear ionatan,
Sorry for the breifness. My code works for anything but codecademy won't let me move on with the next lesson. The code identation is becuase I copied and pasted. Is there a different way to do it that is better?


#4

You could select all your code after pasting it then pressing the " </> " in the editor or you could use " ` " that is before the "1" on the keyboard by placing it before and after your block of code, that you want to post, (three of them before and after) I place them on separate lines from the code on top and bottom, I don't know if that's necessary though.