Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to find the sum of digits of a number in python

num = int(input("Enter the number: "))
sum_of_digits = 0
while num > 0:
    digit = num % 10
    num //= 10
    sum_of_digits += digit
print("The sum of digits is", sum_of_digits)
Source by kite.com #
 
PREVIOUS NEXT
Tagged: #find #sum #digits #number #python
ADD COMMENT
Topic
Name
5+7 =