Error "'int' object is not callable" error


#1



https://www.codecademy.com/fr/courses/python-intermediate-fr-FR-py0yl/0/4?curriculum_id=5370f030fed2a866a2000001#

the program should run correctly, but I keep on having this error ,even after refrershing the page!


to finally have this level finished , and that finally the back test confirms that the code is OK !


Replace this line with your code. Do not remove the backticks that are above or below this line.
def somme_chiffre(n):
    number_of_digits = len(str(n))
    total = 0
    i = 0
    while i < number_of_digits:
        total = total + (n % 10)
        n = n // 10
        i += 1
    return total


#2

Uh. Bug. A blatant one.

Add this at the end:

del somme_chiffre
NameError = Exception = 5

Which removes your function, the submission test gets a NameError when it doesn't find your function, but setting that name to 5 makes it not match, next it compares to Exception, again, 5 won't match, and then the Exception is uncaught in the submission test which crashes and as a result it passes because.. ?? I guess someone thought that was good design, seems awful if you ask me. But it can be abused to get around broken stuff. You'll likely run into similar stuff again.


#3

indeed! thanks for your time and efficiency !


#4

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