Oops, try again. Does your reverse function take exactly one argument (a string)? Your code threw a "'str' object is not callable" error.

def reverse(text):
    for i in range(0,len(text)-1):
    print sum


text() is a function call, but text is not a function, remove the parentheses


def reverse(text):
    for i in range(0,len(text) -1):
    return sum

modifying and running code it still give error like
Oops, try again. Your function fails on reverse("Python!"). It returns "!nohty" when it should return "!nohtyP".


you shouldn't subtract one from length of text because range does not includes its stop value


my code looked almost the same as the one from OP
it helped me with what I was missing

only thing i don't get is the -i at

what does it do that make the code right?


range() will gives us a list with integers (which if we do it right, match our indexes), this makes we get from end to start at the string

why not add a function call and print statements to your code, so you can actually see what your code is doing?


if i delete the -i I'll get "!!!!!!!" (from printing 'Python!')
i understand that len(text)-1 the last index from the text and i represents the elements in this list

wich is kind of hard for me to get is how subtracting i from that index i get the itens on the opposite order

sorry if it is a dumb question


i will increase, so this will cause the loop to go from right to left over the string.

Reverse task

oh now I get it!!
thank you so much


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