4.digit_sum


#1

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

So I figured to turn n into a str, and the hint reminded me I had to turn the characters of the string back to int. Can smn tell me why this doesnt work?

def digit_sum(n):
    string_num=str(n)
    totalsum=0
    for c in string_num:
        totalsum+=int(c)


#2

you forgot to return the totalsum after you calculated it


#3

Nice! Thank you :slight_smile: I can't believe I always focus on the hard stuff and not the small mistakes :slight_smile: