So this was my code for the digit_sum part of the section and quite frankly, the section did give me a lot of issues of all the sections of Python. Even though I got the part right, I still need some help understanding them so I am going to ask you guys some questions.
def digit_sum(n): total = 0 nstring = str(n) for digit_sum in nstring: total = total + int(digit_sum) return total print digit_sum (314)
We set our total to zero, why did we do that?
I know that the key to the whole problem was the "total = total + int(digit_sum)" part but I don't get how it is supposed to give us the sum of a number's digits. Can anyone please help explain to me how it would work in regards to adding up the digits of 314?