the code works great and prints the correct sum of the numbers, however Codecademy will not accept my code! help much appreciated
Error msg states "Oops, try again. Your function fails on digit_sum(434). It returns None when it should return 11.
The prompt is:
Write a function called digit_sum that takes a positive integer n as input and returns the sum of all that number's digits.
For example: digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4.
(Assume that the number you are given will always be positive.)
Check the hint if you need help!
def digit_sum(n): num_list =  n = str(n) for i in n: num_list.append(int(i)) print sum(num_list) digit_sum(12345)