There is my code:

def digit_sum(n):
    total = 0
    for i in str(n):
        return total += int(i)
    return total

I don't know how close i am to the right code, but i'm getting this error message:

"Oops, try again. Does your digit_sum function take exactly one argument (a positive integer)? Your code threw a "object of type 'int' has no len()" error."



return total += int(i)

you can't update a variable and return it at the same line. Which of the two should this line do?


It was the last thing i tried, but I figured it out. Thank you.