4. digit_sum


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/4?curriculum_id=4f89dab3d788890003000096#


It says I did it correctly, but I'm not entirely sure. I had it print out the results and it gave me a series of numbers and letters.


I expected just the numbers


def digit_sum(n):
    str_n=str(n)
    digit_list=[]
    total=0
    for char in str_n:
        total= int(char)+total
    return total
print digit_sum


#2

That's because you're calling the function but you're not inputting anything.

print digit_sum(input)

#3

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