4. digit_sum I'm right but it says I'm wrong


#1

It says "Oops, try again. Your function fails on digit_sum(434). It returns None when it should return 11."
but when I tested it out, it returned 11.

def digit_sum(n):
    x = 0
    while n > 0:
        y = n % 10
        x += y
        n = n // 10
    print x
digit_sum(434)

#2

Ah... I see what happened.
I did print instead of return


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.