My code works fine, but my general doubt is how does the modulus works?
If I take digit_sum(432)
After 2 iterations - sum = 5 and n = 4
so in the next iteration why is 4%10 is = 4
I expected it to be 0 or some absurd value like 6(10-4 = 6)
def digit_sum(n): sum = 0 while n>0: r= n%10 sum = sum +r n=n/10 return sum