"Sum of digits : Given a three-digit number. Find the sum of its digits." - python coding question

 


 

CODING QUESTION

Given a three-digit number. Find the sum of its digits

SOLUTION

sum=0
n=int(input())
sum=sum+n%10
n=n//10
sum=sum+n%10
n=n//10
sum=sum+n%10
print(sum)

Input : 179

Output : 17