15.4 Error 434 on digit_sum function


#1

Hello everyone,

I appeal to your skills because I find myself stuck while I peeled a bunch of topics about it. This is the compiler's answer that I can't get around :

"Oops, try again. Your function failed on 434 as input because your function indicates " 'int' object is not callable" error"."

Here is my code :

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

Can anyone help me please ?

Thank you very much in advance

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


#2

your code is fine, and it would work on the english track, but this exercise seems bugged.

here is a workaround:

def somme_chiffre(n):
    return somme_chiffre

#3

Allright, it works well now !

Thanks for the tip.

Cheers from France :slight_smile:


#4

oh, one more thing if you add a function call:

def somme_chiffre(n):
     compte = 0
     for x in str(n):
         compte += int(x)
     return compte
print somme_chiffre(434)

(or multiply function calls) you will see your code return the correct thing, the exercise is just bugged


#5

Yes, Correct. I've just noticed it as well.

Thanks again for your help and advices !

:smiley: