def count_evens(values: List[List[int]]) -> List[int]:
"""Return a list of counts of even numbers in each of the inner
lists
of values.
>>> count_evens([[10, 20, 30]])
[3]
>>> count_evens([[1, 2], [3], [4, 5, 6]])
[1, 0, 2]
"""
from typing import * def count_evens(values: List[List[int]]) -> List[int]: """Return a list of counts of even numbers in each of the inner lists of values. >>> count_evens([[10, 20, 30]]) [3] >>> count_evens([[1, 2], [3], [4, 5, 6]]) [1, 0, 2] """ counts = [] for lst in values: count = 0 for num in lst: if num % 2 == 0: count += 1 counts.append(count) return counts # Testing the function here. ignore/remove the code below if not required print(count_evens([[10, 20, 30]])) print(count_evens([[1, 2], [3], [4, 5, 6]]))
Get Answers For Free
Most questions answered within 1 hours.