Hello everybody,
I'm having trouble with the digital_sum exercise of Practice Makes Perfect:

I think I already have the answer; however, I keep getting this error message:

Oops, try again. Your function fails on digit_sum(434). It returns None when it should return 11.

Here is my code:

n = raw_input('Enter number')
def digit_sum(n):
    n = str(n)
    s = 0
    for i in n:
        s = s + int(i)
    print s

The weird part is that I've tried it with 434 and I do get the desired result of 11. Any help?


The hint here is to return a value, not print it. If you wish to print, do it with the return value.

print (digit_sum(434))


Thank you @mtf
hate to recognize it was a misreading mistake :stuck_out_tongue: