Probability Calculator

Tell us what’s happening:
I got two test cases cleared but the last one shows error.
Can anyone help me with this?
i have attached the code for finding the probabilty.
FAIL: test_prob_experiment (test_module.UnitTests)

Traceback (most recent call last):
File “/home/runner/ZealousExcellentConditional/”, line 31, in test_prob_experiment
self.assertAlmostEqual(actual, expected, delta = 0.01, msg = ‘Expected experiment method to return a different probability.’)
AssertionError: 0.69 != 1.0 within 0.01 delta (0.31000000000000005 difference) : Expected experiment method to return a different probability.

Ran 3 tests in 0.005s

FAILED (failures=1)

Your code so far
def experiment(hat, expected_balls, num_balls_drawn, num_experiments):
temp_ =
needed_balls =
success = 0
ch_lst =
for k,v in expected_balls.items():
for i in range(v):
needed_balls = copy.deepcopy(temp_)
for cycle in range(num_experiments):
ch_lst =
for j in range(num_balls_drawn):
ch_rand = random.choice(hat.contents)
check_balls = all( item in ch_lst for item in needed_balls)
if check_balls:
success += 1
prob = success / num_experiments
return prob

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36.

Challenge: Probability Calculator

Link to the challenge:

in for loop you should create a copy of hat.contents like:
balls = copy.deepcopy(hat.contents)


like draw in Hat Class