Can anyone please explain me why my code is not working? I get an error: Your function fails on digit_sum(434). It returns None when it should return 11.
What is wrong? It also doesn't print the sum of 123 when I input in the function
def digit_sum(n): total=0 for i in range(len(str(n))-1): lastnum = n%10 total = total + lastnum n = n/10 print digit_sum(123)