Hey!
It seems to me like the calculator is working fine, but can’t pass the tests. Could you give any advice to fix this?
Here is the link to my replit:
import random
class Hat:
def init(self, **kwargs):
self.contents =
for ele in kwargs:
for time in range(kwargs[ele]):
self.contents.append(ele)
def draw(self, num_balls):
self.list_of_strings =
self.contents_copy = self.contents.copy()
if num_balls >len(self.contents):
self.list_of_strings = self.contents
else:
for time in range(num_balls):
ball = random.choice(self.contents_copy)
self.contents_copy.remove(ball)
self.list_of_strings.append(ball)
return self.list_of_strings
def experiment(hat, expected_balls, num_balls_drawn, num_experiments):
count_true = 0
for one in range(num_experiments):
state = True
working_list = hat.draw(num_balls_drawn)
for k in expected_balls.keys():
if working_list.count(k) < expected_balls[k]:
state = False
if state:
count_true += 1
return count_true/num_experiments