Oops, try again. Your function fails on digit_sum(434). It returns 4 when it should return 11.
I get the error that says it returns 4 instead of 11. Also I tried using "while" instead of "if" in line 6, but it goes to infinite loop. What is my mistake? Where should I correct it.
def digit_sum(n): n = int(n) sums = 0 rem = n % 10 quo = n // 10 if (quo > 9): n = rem sums = sums + rem return sums