15/4 somme_chiffre



def somme_chiffre(n):
totalx = 0
strn = str(n)
for x in strn:
totalx += int(x)
return totalx

print somme_chiffre(1234) # for test


Is there a question to go with this post, or is this just a solution?

Y at-il une question d'aller avec ce poste, ou est-ce juste une solution?


yes this code is just but it said me error """ Oups, merci de réessayer.
Votre fonction a échoué sur 434 comme entrée car votre fonction indique "'int' object is not callable" error.


I went through this module yesterday, and found a few lessons were impossible to pass without a workaround. Fortunately we have some gurus here who have come up with solutions, per se. Maybe not actual solutions to the exercise, which we should still solve, but solutions to the SCT issue.

After your code above, add this and submit...

def somme_chiffre(n):
    return somme_chiffre


thanks but I have solve this CodeCademy bug by adding this line at the end:

Exception = "somebody should get around to fixing this..."