7. Reverse


I was wondering why this does not seem to work. My goal here is to convert the text to a string, read from it and input the characters from the string in the front of the list reversed_text
I know this is different than methods on here, but was wondering if someone could pinpoint why this doesn't work?

Error Message: Your code looks a bit off--it threw a "list index out of range" error. Check the Hint if you need help!

def reverse(text):
    original = str(text)
    reversed_text = []
    for char in original:
    return reversed_text


Surely it is already a string?

reversed_text[0] Doesn't exist because there are no elements in that list.
And it's probably meant to hold strings (single characters), meaning that the first element would be a string, so you would be attempting to append to a string, which isn't possible.
Consider what action you're trying to do and then find out how to do it. You're doing too much guessing here.


remember, list index starts at 0 and ends at n-1. so when you have the word "test" you have four characters and need to start at list index 3!


3 posts were split to a new topic: Reverse


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