which should be passes but are not counted that way. That means your check
check = all(item in hat.dict.items() for item in expected_balls.items())
is not working correctly. It looks like it only checks if all the items (keys for dicts) are in both dicts, and not that the numbers in the draw are greater than or equal to the ones in the expected.
One of your self.contents is also typo’d as self.content too, but I don’t think that matters here.
You are absolutely right! My check was not functioning how i thought it would be. Thank you very much!
I replaced the check with these 2 for loops to match the key value pairs in 2 dictionaries. It is a bit long winded and would like to ask if there is a shorter way of doing this? maybe like in a dictionary comprehension etc.
Thank you.
type or paste code here
``` for i in range(num_experiments):
hat.draw(num_balls_drawn)
for k1, value1 in hat.dict.items():
for k2, value2 in expected_balls.items():
if k1 == k2 and value1 >= value2:
correct += 1
if correct >= len(expected_balls):
correct = 0
match += 1
else:
correct = 0