4.somme_chiffre


#1



I'm stuck at the exercice 4 in Practice Makes Perfect


Oups, merci de réessayer. Votre fonction a échoué sur 434 comme entrée car votre fonction indique "'int' object is not callable" error.

Why it don't work?


Replace this line with your code. 
def somme_chiffre(n):
    a=1
    somme=0
    liste=[]
    for i in range(len(str(n))):
        b=(n%(10*a)-(n%a))/a
        liste.append(b)
        a=10*a
        somme+=b
    return somme


#2

Please post a link to the exercise. It's a real pain searching for it. Thank you.

If I'm not mistaken, this lesson may have a bug in the SCT, but will need to check it to see.


#3

Link to the exercise: C'est en forgeant qu'on devient forgeron: somme_chiffre

Yes, there is a bug in the submission correctness test (SCT) for this exercise. Add this workaround at the end of your code to pass ...

class str(object):
    def __add__(self, other):
        return True

#4

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