<In what way does your code behave incorrectly? Include ALL error messages.>
I keep getting an error message and can’t figure out what is wrong. Here’s the message:
Oops, try again. Does your reverse function take exactly one argument (a string)? Your code threw a “‘str’ object is not callable” error.

Any ideas?

Here’s my code:

def reverse(text):
    length = len(text)
    new_word = []
    while length >= 0:
        length -= 1
        return ''.join(new_word)   


you use brackets, not parentheses, to access a character in a String at a specific index.
So it should be new_word.append(text[length])


also getting “Oops, try again. Your code looks a bit off–it threw a “string index out of range” error. Check the Hint if you need help!”


oh sorry, I should have caught that before, you need to start at length - 1 since index starts at 0. if its a 5 letter word the 5th letter is actually at index 4


def reverse(text):
rev =[]
for i in range(0,len(text)):
i = len(text)-(i+1)
#print text[i]
return ‘’.join(rev)
#this is the simplest way to get reverse…thanks


def reverse(text):
length = len(text) - 1
new_word = []
for i in text:

    if length >= 0:
        length -= 1

return ''.join(new_word)


i think this is working also


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