7. reverse


#1

I do not understand how I am meant to write the code so that any text is reversed. Can anybody help me as I do not remember ever having to reverse text.


#2

well , could you show me what was your first code i mean what did you try to do ? :confused:


#3

For me, the key was using lists. I went over the list section again and it really helped.


#4

I've just got the function sorted.
My code is just this:
def reverse(text):
letters = []
for reverse in letters:

Please help me.


#5

I added an empty list, but I don't know what to add next.


#6

Like this:
def reverse(text):
text_r=""
for i in range(len(text)-1,-1,-1):
text_r+=text[i]
return text_r
print reverse("Python!")


#9

I've got it sorted now, thank you. This was a great help.


#14

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