I have written a Python function that takes an integer as input and returns the sum of all that number's digits:
def digit_sum(n):
n_lst = list( str(n) )
n_sum = 0
for i in range( len(n_lst) ):
n_sum += int( n_lst[i] )
return n_sum
print( digit_sum(1234) ) # 10
Now I wonder if there is a more concise way of doing this perhaps, using a built-in function or list comprehensions?