Digit sum

Hi, why when I test the code with x = 1234, it gives me 4 instead of 10???
Here is my code:

def digit_sum(n):
total = 0
total += n % 10
n = n // 10
return total
print digit_sum(1234)


What could this value be? Where does it come from? Once you figured out where does this value comes from, what does this say about your code?

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