def digit_sum(n):

num = str(n)

sum = 0

for i in num:

sum = sum + int(i)

return sum

print digit_sum(1234)

def digit_sum(n):

num = str(n)

sum = 0

for i in num:

sum = sum + int(i)

return sum

print digit_sum(1234)

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