logo CodeStepByStep logo


Language/Type: Python basics loops
Author: Allison Obourn (on 2016/09/21)

Write a function named count_even_digits that accepts two integers as parameters and returns the number of even-valued digits in the first number. An even-valued digit is either 0, 2, 4, 6, or 8. The second value represents how many digits the number has. The second value is guaranteed to match the number of digits in the first number.

For example, the number 8546587 has four even digits (the two 8s, the 4, and the 6), so the call count_even_digits(8346387, 7) should return 4.

You may assume that the values passed to your function are non-negative.

Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.