Here’s a link to the exercise:

I keep getting this error and can’t figure out what’s wrong: 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.

Any ideas?

Here’s my code:

def digit_sum(n):
    numbers = []
    answer = 0
    for let in n:
    for dig in numbers:
        answer += dig
    return answer


str(n) returns the integer as a string. So 1234 is converted into “1234”.

int(dig) returns the string digit as an integer. So a string of “1” is converted into an integer 1.

Now look at your code. You are converting them. But think about what it means to return a value. What happens to the value being returned? Where should be assigned?


I have the same issue


If you’ve any problems with this lesson then please create a new topic

you shouldn’t post on other’s topic.

Follow this link It’ll help you to create a new topic :slight_smile:


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