4. My code isnt working


#1



4.

hey
my code for number 4 of practice makes perfect in Python seems not to work
when I try my code it tells me that my function didn't work on 434 saying that "'int' object is not callable"
I'm French so the names of the functions aren't the same but can you understand the whole thing and most important why it isn't working ?
thanks


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


#2

Please post a link to the exercise. Thank you.


#3

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

But this is in french


#4

There is a bug in the SCT for this lesson. Fortunately a member found a work around to get through this exercise.

Assuming your code is correct (which it is) add this to the end...

def somme_chiffre(n):
    return somme_chiffre

Supplement

For added practice and study, here is a solution that uses a list comprehension...

def somme_chiffre(n):
    return sum([ int(i) for i in list(str(n))])