Problems with reverse


#1


Hello!

I'm currently stuck at the exercise reverse.

After running the code below, I get the following error: Does your reverse function take exactly one argument (a string)? Your code threw a "'str' object is not callable" error.

In the console, it just prints "none"


Here's the code:

def reverse(text):
    result = ""
    text = str(text)
    for i in range(len(text)-1, -1, -1):
        result += text(i)
    return result


#2

here:

result += text(i)

to access a string by index use square brackets, using parentheses will mean the string will be called like a function, which gives an error (str obejct is not callable)


#3

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