4. digit_sum (error using sum)



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

I haven't been able to figure out what is wrong with my code.

def digit_sum(n):
    n = str(n)
    numbers = []
    for char in n:
    print sum(numbers)


Hi @wamplify,

The sum function is not the problem. You can use it for this exercise.

Instead of this ...

    print sum(numbers)

... you need to return the result, as follows ...

    return sum(numbers)


Thanks! I figured it was probably a silly mistake.