Robust Python generator, then a weighted one

0
Remix
  1. Write a Python generator that yields the numbers of an input list, with unit tests. Handle edge cases such as None values and an empty list.
  2. Change it to yield numbers from the list at random according to a given probability for each, and test that the distribution is right.
GoogleCodingLast asked Sep 2025
No answer yet. Write the first one; the best answer gets endorsed.