Traceback (most recent call last):
File "python", line 10, in
File "python", line 4, in digit_sum
TypeError: 'int' object is not iterable

Oops, try again. Does your digit_sum function take exactly one argument (a positive integer)? Your code threw a "'int' object is not iterable" error.

It should work. It decode all the stuff in the function and append it to my list

def digit_sum(number):
    numbers = []
    total = 0
    for key in abs(number):
    for stuff in numbers:
        total += stuff
    return total


this line:

for key in abs(number):

number is a integer, you can't loop over it. If you want to do this, you will need to cast it to a string (using: str() ), you can loop over a string. Don't forget to cast back to a int when adding it to total


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