Programming Examples
Python program to accept a integer number and find its sum of digit
Write a program to accept a integer number from user and find its sum of digit.
Sample 1:
Input : 123
Output : Sum of Digit : 6
Sample 2:
Input : 1234
Output : Sum of Digit : 10
Solution
num=int(input("Enter any Number : "))
sum=0
while num>0:
digit=num%10
sum=sum+digit
num=num//10
print("Sum of Digit : ",sum)
Output
Enter any Number : 123
Sum of Digit : 6