If I want to find the sum of the digits of a number, i.e.:
932
14
(9 + 3 + 2)
Found this on one of the problem solving challenge websites. Not mine, but it works.
num = 0 # replace 0 with whatever number you want to sum up print(sum([int(k) for k in str(num)]))