# Probleme avec somme des chiffres 15/4

#1

J’ai consulté le forum mais je n’y arrive pas.
merci de m’aider!

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

def somme_chiffre(n):
t = n % 10
while n > 0:
n = n // 10
t = t + n % 10
return t

#2

@textsolver97036,
You should do a refresh Browser

``````**: exponentiation
•^: exclusive-or (bitwise)
•%: modulus, result is remainder
•'//': divide with integral result (discard remainder)

``````
``````def somme_chiffre(n):
t = n % 10
print("t = n%10 :: t-{0} n-{1}".format(t,n) )
print("Begin of WHILE")
while n > 0:
print("\tbegin loop")
print("\tn before :: {0}".format(n) )
n = n // 10
print("\tn = n // 10 :: {0}".format(n) )
t = t + n % 10
print("\tt = t + n % 10 :: t-{0} n-{1}".format(t,n) )
print("\tend loop")
print("End of WHILE")
print("t-{0} n-{1}".format(t,n) )
return t

somme_chiffre(100)
``````

Output

``````t = n%10 :: t-0 n-100
Begin of WHILE
begin loop
n before :: 100
n = n // 10 :: 10
t = t + n % 10 :: t-0 n-10
end loop
begin loop
n before :: 10
n = n // 10 :: 1
t = t + n % 10 :: t-1 n-1
end loop
begin loop
n before :: 1
n = n // 10 :: 0
t = t + n % 10 :: t-1 n-0
end loop
End of WHILE
t-1 n-0
``````

##===============================

++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.