#511 · Lists · Beginner · 25 XP · about 3 min
Write count_odds_evens(nums) that counts the even numbers and the odd numbers in a list and returns both counts as a tuple (evens, odds), with the evens first.
0 is even, and negative numbers work the same way: -4 is even and -3 is odd.
count_odds_evens([1, 2, 3, 4, 5]) # returns (2, 3) count_odds_evens([0, -4, -3]) # returns (2, 1) count_odds_evens([]) # returns (0, 0)
First solves only, ranked by stars and then time.