Write a Python function to to find the sum of all digits of a given integer


Topic: Write a Python function to to find the sum of all digits of a given integer

Solution

def sum_of_digits(num):
  if num == 0:
    return 0
  else:
    return num % 10 + sum_of_digits(int(num / 10))



List all Python Programs