4.digit_sum


#1

I’m not sure what it is telling me with this error message.

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.

```python

def digit_sum(n):
return sum(n % 1000 + n % 100 + n % 10 + n % 1)

<do not remove the three backticks above>

#2

sum() is a built in function which takes an iterable like a list as argument, n % 1000 + n % 100 + n % 10 + n % 1 is not an iterable.

you can just use + if you want to add integers together


#3

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