Digit_sum


#1




Hello to everyone. I have a problem with: digit_sum task.


I am a bit confused why codeacademy compilator does not want to accept my code. It works okay in my Python IDE. Could somebody of you be so kind and explain to me where I was wrong. Thank you so much.


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


#2

besides printing the sum of digits, you should also return it.


#3

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