Digit_sum


#1



Need Little help here


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


def digit_sum(n):
    sum=0
    while n > 0 :
        r=n%10
        sum+=r
        n=n/10
    else:
        print sum


#2

Any function that does not return anything implicitly returns None type.The instructions expect you to return a value in that function.


#3

Thank u it solved the problem


#4

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