# Probability Calculator need help

I think i dont get the test

``````import random
import copy

class Hat:
def __init__(self, **balls):
self.contents = []
for k, v in balls.items():
for i in range(v):
self.contents.append(k)

def draw(self,number):
listofdraws = []
choices = []
if number > len(self.contents):
return self.contents
else:
for i in range(number):
choice = random.choice(self.contents)
listofdraws.append(choice)
#Removing the choice to append it later
self.contents.remove(choice)
choices.append(choice)
for i in choices:
self.contents.append(i)
return listofdraws

def experiment(hat, expected_balls, num_balls_drawn, num_experiments):
times = 0
expected = []
#Get the expecteds in list(str)
for k,v in expected_balls.items():
for i in range(v):
expected.append(k)
for time in range(num_experiments):
choices = hat.draw(num_balls_drawn)

#Each time the loop begins it does a copy

c_expected = copy.copy(expected)
c_choices = copy.copy(choices)
count = 0
for i in c_expected:

# it loops in every object in
# ['blue', 'blue', 'green']

if i in c_choices:

#If for example 'blue' is in (copy)_choices, gets removed

c_choices.remove(i)
count+=1
if count == len(expected):
times += 1
else:
break
return times/num_experiments
``````

The code fails in the second and third tests, but it seems to work well
``````Traceback (most recent call last):