"Oops, try again. Your function fails on digit_sum(434). It returns 22 when it should return 11."
Python is saying that digit_sum(434) is adding to 22. When I print to interpreter, it shows as 11.

I expected it to return 11.

numberz = []

def digit_sum(n):
    x = str(n)
    for digit in x:
    print sum(numberz)
    return sum(numberz)


place this line:

numberz = []

inside your function, the checking script calls the function only, not the whole script, which means the list doesn't get emptied if this line is not inside the function, which can cause leftovers


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