Sum of Digits

Easy 20 XPMathLoops

Commonly asked at TCS, Infosys, Zoho

Read a non-negative integer and print the sum of its digits. Try solving it with % and // instead of converting to a string.

Input
One non-negative integer n.
Output
Sum of the digits of n.

Sample 1

Input

4721

Output

14

Explanation: 4 + 7 + 2 + 1 = 14

Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.
The solution unlocks after 3 submissions.