I'm trying to follow along with the lesson, and I wrote this out:
def digit_sum(n): totalsum = 0 while n > 0: digit = n % 10 totalsum = totalsum + digit return totalsum n = n // 10 print totalsum
But it gives me this error:
Oops, try again. Your function fails on digit_sum(434). It returns 4 when it should return 11.
What am I doing wrong? I've been relooking it over and over for over a day, and I can't think of what went wrong??