Q. Write a program to find the sum of digits of an integer number, input by the user.


Answer :-


num = input("Enter a number :-")
sum = 0
for i in num :
    sum += int (i)

print("Sum of digit :- ", sum)


Output :-

Enter a number :-123
Sum of digit :-  6
>>>

4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post