I had some difficulty understanding how the answer,
total = 0
while x > 0:
total += x % 10
x = x // 10
was derived from the instruction set,
“Write a function called digit_sum that takes a positive integer n as input and returns the sum of all that number’s digits. For example: digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4. (Assume that the number you are given will always be positive.)”
I understand how to start off a definition. After that, I am lost. Anyone care to break it down “dummy style” for me? Thank you in advance!