Error "'int' object is not callable" error


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


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.


indeed! thanks for your time and efficiency !


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