Add up the individual digits of a number.
Input
A single line containing a non-negative integer n.
Output
The sum of the digits of n.
Add up the individual digits of a number.
A single line containing a non-negative integer n.
The sum of the digits of n.
Example 1
1234
10
1 + 2 + 3 + 4 = 10.
Example 2
0
0
The only digit is 0.
Example 3
99
18
9 + 9 = 18.
You can treat the number as a string and add up its digit characters.
Each character c can be turned into its numeric value and summed.
Read the number as text and sum the numeric value of each digit character.
s = input()
print(sum(int(c) for c in s if c.isdigit()))
Tell us what needs to change, who it affects and any important deadline. We will review the context and reply with useful next questions.