Traceback (most recent call last):
File "python", line 8, in
File "python", line 4, in digit_sum
TypeError: 'int' object is not iterable
The error message says that an integer is not iterable. I get that but in the second line of code the integer is turned into a string, so why still this error?
def digit_sum(n): str(n) sum = 0 for i in n: sum += int(i) return sum print digit_sum(1234)