I've been searching for a way to solve this for an hour, and I'm getting really discouraged.
I'm getting this error:
"Traceback (most recent call last):
File "python", line 14, in
File "python", line 3, 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."
What I want to do is be able to separate every letter/number in n, even if they are not already separated (ex: '143' would be '1', '4', '3', not '143'). and add them together, x. Ideas for separating each item in a list? Something like n[0:] or something?
Thank you in advance.
def digit_sum(n): n ==  for num in n: x == 0 if num % 1 == 0: x += num elif num == str('num'): int(num) x += num else: print 'error'
edit: I realize there is a lot wrong with my code, I'm still learning.