Loading...
Loading...
Loading...
A bank form checks an ID number by adding all of its digits. Given an ID n, print the sum of its digits.
Example
Input
123
Output
6
1 + 2 + 3 = 6.
Try the problem first. Open one hint at a time.
The last digit of n is n % 10.
Add the last digit to a total, then remove it with n // 10, and repeat until n is 0.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor