Digit_Sum help Requested


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/4?curriculum_id=4f89dab3d788890003000096


Error message: "Oops, try again. Your function fails on digit_sum(434). It returns None when it should return 11." Not sure how to amend the code correctly.


Replace this line with your code. 
def digit_sum(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    print sum


#2

Try changing:
print sum
into
return sum


#3

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