Digit_sum won't print


#1




My code works, but won't print to the console


n = raw_input("Type a positive number")
def digit_sum(n):
    numbers = []
    for i in str(n): 
        numbers.append(int(i))
    numbers = sum(numbers[:])
    return numbers
    print numbers
    
    
digit_sum(n)


#2

print is unreachable after return.


#3

Thanks! I didn't know that.


#4

Actually, anything after return is unreachable unless it is elif or else, which goes along with a change of context.


#5

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