4 digit_sum


#1



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

Your function fails on digit_sum(434). It returns 4 when it should return 11.

Can anyone help me with this? This is driving me nuts. Thanks in advance!


def digit_sum(n):
    count=0
    count1 = str(n)
    for a in count1:
        m=int(a)
        count+=m
        return count


#2

Yes it will fail on that instance as the interpreter said... Indentation on the return causes the issue.

def digit_sum(n):
    count=0
    count1 = str(n)
    for a in count1:
        m=int(a)
        count+=m
    return count
print(digit_sum(434))

Try this!

Hope this helps! :smile: