Why is this not working?


#1
number = raw_input("Enter a number")
def digit_sum(n):
    total = 0
for i in str(n):
    total += int(i)
print total

digit_sum(number)

When I run this I get this error

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

But when I enter 434 I get 11


#2

Correct indentation:

number = raw_input("Enter a number")
def digit_sum(n):
    total = 0
    for i in str(n):
        total += int(i)
    print total

Does the exercise expect you to test run the function?

digit_sum(number)