program in python to input any integer number and calculate its sum of digit


Write a program in python to input any integer number and calculate its sum of digit

-------------------------------------

n=int(input("Enter any Number : "))

sum=0

while n>0:

   digit=n%10

   sum=sum+digit

   n=n//10

print("Sum of Digit : ",sum)

-------------------------------------

Output :-

Enter any Number : 456

Sum of Digit :  15


Post a Comment

0 Comments