Digit_sum function


#1

Can someone please explain to me what is wrong with my code.

def digit_sum(n):
num_string = str(n)
num_list = []
total = 0
for digit in num_string:
num_list.append(digit)
for i in num_list:
total += int(i)
print total

It seems to be working when I try it, I can't go forward
Please help


#2

Wait, nevermind. Got it


#3

So what did you do I did basically the same thing and it out puts the correct sum but I fear I am having the same problem you had at first?


#4

You have to use the return statement in a function. if you don't python will return "None"
change print total to return total