Python, Probability Calculator error

Tell us what’s happening:
Hello guys!

So my code for the Probability Calculator is almost done, but i keep getting a difference in the last test. It’s not much of a difference but I haven’t been able to get the requested result, even tho I’m not that far way from it. Could you take a look and guide me?

Thanks!

Your code so far
import random
import copy

def experiment(hat, expected_balls, num_balls_drawn, num_experiments):
expected_balls_list =
i = 0
i2 = 0
matchs = 0
for k, v in expected_balls.items():
while i < v:
expected_balls_list.append(k)
i = i + 1
while i2 < num_experiments:
expected_balls_list_copy = copy.deepcopy(expected_balls_list)
deep_copy = copy.deepcopy(hat)
balls_drawn = deep_copy.draw(num_balls_drawn)
# print(balls_drawn)
# print(expected_balls_list)
for ball in expected_balls_list_copy:
if balls_drawn.count(ball) == expected_balls_list_copy.count(ball):
expected_balls_list_copy.remove(ball)
# print(balls_drawn.count(ball), expected_balls_list_copy.count(ball))
matchs += 1
i2 = i2 + 1
# print(f’We found {matchs} matchs in the experiment’)
prob = matchs / num_experiments
print(prob)
return prob

class Hat:

def __init__(self, **kargs):
    self.population = {}
    self.contents = []
    for k, v in kargs.items():
        self.population[k] = v
        i = 0
        while i < v:
            self.contents.append(k)
            i = i + 1
    # print(self.contents)

def draw(self, balls_to_draw):
    balls_drawn = []
    if balls_to_draw >= len(self.contents):
        return self.contents
    balls_drawn = random.sample(self.contents, balls_to_draw)
    for ball in balls_drawn:
        self.contents.remove(ball)
    return balls_drawn        

Your browser information:

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

Challenge: Probability Calculator

Link to the challenge: