ERROR: Oops, try again. Your function fails on digitsum(434). It returns 22 when it should return 11.
EDIT : Writing this function in the terminal on my mac returns the correct sum, so I'm thinking it's a code academy bug
I decided to take on the extra challenge of not converting the number to a string and then back to an int. Took me a couple days, but I figured out how to set it up.
However, I am running into a problem.
So when I run my recursive (possibly using wrong term here) function, it does print out the correct sum. However, CodeAcademy sees it as a different number for some reason. In the case of 434, it sees it as 22, not 11, even though my function returns 11.
Can someone give me some insight on what I might be doing wrong? Or is this an error on codeacademy's part?
temp_number =  def digit_sum(n): remove_last_digit = n//10 temp_int = remove_last_digit temp_number.append(n%10) #print temp_int, temp_int % 10, temp_number if temp_int != 0: return digit_sum(temp_int) print sum(temp_number) return sum(temp_number) digit_sum(434)