Reverse


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/practice-makes-perfect/exercises/reverse?action=lesson_resume

<In what way does your code behave incorrectly? Include ALL error messages.>
Pleaase help me. What is wrong with this code. I get “cba!nohtyp” instead of “!nnohtyp”. What went wrong with this code?

<What do you expect to happen instead?>


def reverse(text):
  x = list(text)
  for i in range(0, len(x)):
    print x[len(x)-1]
    x.remove(x[len(x)-1])

#2

you will need to create a string which contains the reversed string so you can return it.


#3

Thanks. But still, I don’t understand. I think I need a step by step explanation :slight_smile:


#4

we need to create a function which returns a reversed string, so we will need to make a string to which we append the characters in reversed order. That is the challenge, what have you got?


#5

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