Digit_sum -- why can't you print after return?


#1


  1. Digit_sum, 15. Practice makes perfect

I'm confused why you cannot print after a return. Maybe I don't fully understand what return does, but I assumed it just returns the value of the function. Why can I not print this value from within the function after returning it?

I expect the total to print


def digit_sum(n):
    numbers = str(n)
    total = 0
    for i in numbers:
        total += int(i)
    return total
    print total
    
digit_sum(434)


#2

3 posts were merged into an existing topic: Return


#3