Answers for "python sum each digit of a number"

3

how to sum digits of a number in python

number = 123 # the number you want summed up
sum_of_digits = 0 
for digit in str(number):
  sum_of_digits += int(digit)
  
print(sum_of_digits) # printing the final sum of number
Posted by: Guest on April-25-2020
2

sum of any numbers in python

sum(list(map(int,input().split())))
Posted by: Guest on December-02-2020

Code answers related to "python sum each digit of a number"

Python Answers by Framework

Browse Popular Code Answers by Language