Digit_sum


#1



def digit_sum(n):
    digits=[]
    for d in str(n):
        digits.append(int(d))
        b=sum(digits)
        return b


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


Replace this line with your code. 
Can somebody help me to check or correct it? I have struggled few days for this one.


#2

you should first append all digits to your list, then after/outside the loop get the sum of the list and return the total


#3

Thank you. I have solved the problem


#4