Python program to find sum of digits in a number - Python for Data Analytics

Python Programs | Python Tricks | Solution for problems | Data Cleaning | Data Science

Python program to find sum of digits in a number

The program takes in a number and finds the sum of digits in a number.
*************PROGRAM***************


n=int(input("Enter a number:"))
tot=0
while(n>0):
    dig=n%10
    tot=tot+dig
    n=n//10
print("The total sum of digits is:",tot)

No comments:

Post a Comment