The first time i tried to do this question, i got the error message
"Oops, try again. Your function fails on digit_sum(434). It returns None when it should return 11."
After fiddling around, i figured out my problem lies with my use of "return" and "print".
My question is: when do you use "return" and "print" in a function, and why? The two methods below theoretically both work, however, the program only approved the second one.
def digit_sum(n): x=0 for i in str(n): x += int(i) print x digit_sum(434) def digit_sum(n): x=0 for i in str(n): x += int(i) return x print digit_sum(434)