Published
- 1 min read
python program to find sum of digits of a number using while loop
The solution for this is noted below
python program to find sum of digits of a number using while loop
Solution
# Write a Program to display sum of all digits of a given
# Number N by user
n = int(input('Enter a number : '))
sum=0
while(n>0):
rem = n%10
sum = sum+rem
n = n//10
print('reversed no. is : ',int(sum))
Try other methods by searching on the site. That is if this doesn’t work