Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

sum of digits in python

# Python program to
# compute sum of digits in 
# number.
   
# Function to get sum of digits 
def getSum(n):
     
    strr = str(n)
    list_of_number = list(map(int, strr.strip()))
    return sum(list_of_number)
   
n = 12345
print(getSum(n))
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #sum #digits #python
ADD COMMENT
Topic
Name
9+6 =