Count Odd Digits X52586


Statement
 

pdf   zip   main.py

html

Write a function odd_digits(n) that receives a non-negative integer n and returns the number of occurrences of odd digits in n.

Observation

All integers are assumed written in the usual base 10.

Sample session
>>> odd_digits(2020)
0
>>> odd_digits(7654321)
4
>>> odd_digits(0)
0
>>> odd_digits(222182) + odd_digits(113)
4
Information
Author
José Luis Balcázar
Language
English
Official solutions
Python
User solutions
Python