My code is here.
Console output is:
Probability: 0.179
..E
======================================================================
ERROR: test_prob_experiment (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/probability-calculator-Geoffrey/test_module.py", line 28, in test_prob_experiment
probability = prob_calculator.experiment(hat=hat, expected_balls={"yellow":2,"blue":3,"test":1}, num_balls_drawn=20, num_experiments=100)
File "/home/runner/probability-calculator-Geoffrey/prob_calculator.py", line 39, in experiment
drawn_balls = hat.draw(num_balls_drawn)
File "/home/runner/probability-calculator-Geoffrey/prob_calculator.py", line 26, in draw
drawn = random.choice(list(self.contents))
File "/usr/lib/python3.8/random.py", line 290, in choice
raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence
----------------------------------------------------------------------
Ran 3 tests in 0.186s
FAILED (errors=1)
I should mention that switching between using the hat passed as an arg and using a deep-copy so-far hasn’t affected the results of running the code.