Hello,

The correct code to get the digit sum is below

```
def digit_sum(x):
total = 0
while x > 0:
total += x % 10
x = x // 10
print x
return total
```

However, if I modify the code to be

```
def digit_sum(x):
total = 0
while x > 0:
x = x // 10
total += x % 10
print x
return total
```

It is wrong. Why is that?

Lets assume x = 25

then x = x//10 = 2 (first digit)

then total += x%10 = 5 (second digit)

How does the sequence of the code work?

Please help