Digit_sum error


#1

Hi,
This is my code:

def digit_sum(n):
m=[]
for i in n:
m.append(int(i))
return sum(m)

n=raw_input("positive number: ")
print digit_sum(n)

This code can achieve the function requirement, but always showed a error:
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.


#6

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