Sum of Odd Digits
EasyPractice library · +10 XPmathdigitsloops
Given a positive integer N, compute the sum of its odd digits. For example, if N = 12345, the odd digits are 1, 3, and 5, and their sum is 1 + 3 + 5 = 9.
Input
A single line containing a positive integer N.
Output
A single integer: the sum of the odd digits of N.
Constraints
1 <= N <= 1000
Time limit 1 s (native code; slower languages get more)Memory 256 MB14 hidden tests
Example 1
Input
12345
Output
9
Odd digits are 1, 3, 5. Sum = 1 + 3 + 5 = 9.
Example 2
Input
24680
Output
0
No odd digits. Sum = 0.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
12345
Example 2 input
24680