iq.lab
Python starts when a code cell comes near or you run one
easyLoops and basicsBits and math target 15 min

Numbers with an even digit count

nums is a list of whole numbers, none of them negative. A number's digit count is how many digits it has when written the usual way, with no leading zeros: 47 has two digits, 305 has three, and 0 has one.

Return how many numbers in nums have an even digit count. An empty list gives 0. Leave nums unchanged: the caller may still need it.

Example 1
Inputnums = [47, 305, 8, 1234]Output2

47 has 2 digits and 1234 has 4, both even. 305 has 3 and 8 has 1, both odd.

Example 2
Inputnums = [10, 99, 100, 7000]Output3

10 and 99 have 2 digits and 7000 has 4. 100 has 3.

Example 3
Inputnums = [0, 5, 600]Output0

0 and 5 have one digit each and 600 has three, so none of them counts.

Constraints
  • 0 ≤ len(nums) ≤ 105

  • 0 ≤ nums[i] ≤ 109

Plan it first

Write a line for each before you code, then say them out loud. Compare with the Approach tab afterwards.

⌘+Enter runs 0:00Python starts when a code cell comes near or you run one
Run examples checks the examples. Submit runs every test, including edge cases and, when the problem has one, a speed check on a large input.