15. digit_sum


#1



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


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


When i call digit_sum(434) function it echoes 11 how its supposed to.


def digit_sum(number):
    digstr = str(number)
    digsum = 0
    for d in digstr:
        d = int(d)
        digsum += d
    else:
        print digsum
    
digit_sum(1234)
digit_sum(12)
digit_sum(111)
digit_sum(434)
digit_sum(4334)


#2

but your function doesn't actually return digsum at the end, you need to use the return keyword


#3

Thanks bro, It works now!