My code works fine (i think) but codeacademy simply won't let me pass the level, I print the result the code returns to be sure im getting what i want... and It works! But codeacademy gives me errors like "Oops, try again. Your function fails on digit_sum(1000). It returns 12 when it should return 1."
I think it should work... Can someone help me? Why does it give me an error? Does codeacademy just dont like me?
num =  def digit_sum(n): n = str(n) for x in n: num.append(x) total = 0 print num #num now contains each digit for x in num: total += int(x) print total return total #returns the sum of the digits