Computer Science, asked by sanaapillai, 3 months ago

Q23. Write a Python Program to accept number from user and find the sum of digits in the
Number using while loop.
[Eg: if the user input the number 235, the sum is 10]​

Answers

Answered by mianshahid53gb
2

Answer:

num=int(input("Enter a number: ")) #input from the user.

sum=0.

while(num>0):

digit=num%10.

sum=sum+digit.

num=num//10.

print("The sum of digits is: ",sum)

Similar questions