I understand for this lesson there may be multiple correct answers. In regards to the error code, I only have one "for" argument in my function, so, "yes"? & Im not sure if I am converting the numbers correctly but can't find answers from previous lessons. Some of the error messages haven't always been that helpful and most times it has been an "indentation" error. Can someone help walk me through this code and set me straight?
Oops, try again. Does your digit_sum function take exactly one argument (a positive integer)? Your code threw a "unsupported operand type(s) for +: 'int' and 'str'" error.
Also, they should post these forums by lesson and error code. Just a thought.
def digit_sum(n):# creates fucntion string = str(n)#converts n into a string total = 0 #initiate variable for x in string:#iterate through the string total = total + x#adding all the contents of the string return total# returning the sum of the numbers in the string