The code works correctly. However, I want to know the logic behind breaking the variable 'n' into strings instead of leaving them as integers. When I first approached this problem I didn't think of breaking it into strings. If someone could please explain the logic/reasoning behind this approach it would be greatly appreciated! You all are awesome for assisting, thanks!
#Initiate Code def digit_sum(n): num=[ ] n = str(n) #why do we need to make the values strings? for i in n: num.append(i) total = 0 #initializng the variable print num for i in num: total += int(i) print total return total