12 Program takes in a number and finds the sum of digits in a number using Python

Program:

num = int(input("Enter any number:"))
onum = num
snum = 0
while num > 0:
    rem = num % 10
    snum = snum + rem
    num = num // 10

print("Original Number:",onum)
print("Sum of Number:",snum)


Output:

Program takes in a number and finds the sum of digits in a number using Python

Previous
Next Post »