Digit Sum: Correct Number is Printed but Says Incorrect Number is Returned


My function works and prints out the proper number but it is always saying that it is not returning the correct number.

def digit_sum(x):
    for number in str(x):
    return sum_of_digits
print digit_sum(434)


The list needs to be defined inside the function so it does not carry over previous values from earlier calls.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.