Reverse - 'str' object is not callable


#1



def inverser(texte):
    texte2 = ""
    nombre = len(texte) - 1
    while nombre >= 0:
        texte2 += texte[nombre]
        nombre -= 1
    return texte2
    
print(inverser("coolstory"))


It works but this error always show up :
"'str' object is not callable".

Can you help me please ? :slight_smile:


#2

Hi @fokushy,

There is a bug in this exercise. Add this to the beginning of your code, as a workaround ...

class str:
    def __add__(self, other):
        return True

#3

Thank you for the speed, but it's been several months that I left this exercise aside because I could not solve this error, I returned sometimes to try again but always the same, otherwise, refresh the page does not solve the problem.
The link of the exercise: https://www.codecademy.com/en/courses/python-intermediate-en-FR-py0yl/1/1?curriculum_id=5370f030fed2a866a2000001#


#4

Thanks for the link to the exercise.

The French version of this exercise has a bug in the submission correctness test (SCT). In that version of the exercise, adding this to the beginning of the code will enable your code to pass ...

class str:
    def __add__(self, other):
        return True

#5

Many thanks ! It worked :smiley:


#6