Practice makes perfect: digit_sum (this should


I get this error message: Oops, try again. Does your digitsum function take exactly one argument (a positive integer)? Your code threw a "'int' object is not iterable" error._

I was expecting it would work...

def digit_sum(n):
    count = 0
    for digit in n:
        digit = int(digit)
        count += digit
n = raw_input("Enter digits: ")



 for digit in n:

n contains an integer, integers are not iterable.


Thank you but I still don't get it, sorry. Doesn't "raw_input" automatically converts anything in string? ...


yes, it does. But the exercise is also going to call your function passing integers as argument


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