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.

My code can meet the function requirement and output the right answer. Just don't why always showed error.

def digit_sum(n):
    for i in n:
    print m
    return sum(m)
n=raw_input("positive number: ")
print digit_sum(n)




You were errored probably because you used the same variable "n" in both starting digit_sum and in raw_input.

Change the variable of raw_input to something else along with the variable in print digit_sum()


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