Digit_sum: How to print the sum in the output


#1

def digit_sum(n):
n = str(abs(n))
print (n)
number_set = []
for i in n:
number_set.append(int(i))
return (sum(number_set))

How to print the sum in the output?????


#2

a function only executes when called, so call the function? To print what a function returns, add a print statement before the function call

in the exercise, you might get away with not adding print statement before function call


#3

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