Python - Probability Calculator Project

Can’t run the project. I need help

Always I get the error:

python venv/lib/python3.8/site-packages/distlib/
Traceback (most recent call last):
File “venv/lib/python3.8/site-packages/distlib/”, line 18, in
from . import DistlibException
ImportError: attempted relative import with no known parent package

could you display you code?

import copy
import random

class Hat:

    contents = list()
    drawncontents = list()

    def __init__(self, **kwargs):
        for k, v in kwargs.items():
            for i in range (1, v + 1, 1):

    def draw(self, numballs):
        self.drawncontents = list()
        hatcontent = copy.copy(self.contents)
        ballsinhat = len(self.contents)
        if numballs > ballsinhat:
            return hatcontent
        while numballs > 0:
            numberdrawn = random.randint(0, ballsinhat - 1)
            balldrawn = hatcontent[numberdrawn]
            del hatcontent[numberdrawn]
            numballs = numballs - 1
            ballsinhat = ballsinhat - 1

        return self.drawncontents

def experiment(**kwargs):
    args = list()
    expected = list()
    for k, v in kwargs.items():
    for k, v in args[1].items():
        for i in range(1, v + 1, 1):
    count_prob = 0
    count = 0
    while count <= args[3]:
        if all(elem in hat.draw(args[2]) for elem in expected):
            count_prob = count_prob + 1
        count = count + 1

    return count_prob / args[3]

@paulojveiga1968 I had an issue with the run button being set to “python venv/lib/python 3.8/site-packages/distlib/” instead of the test module “python”. I couldn’t find where to change the run button behavior and had to import the replit again and change the run button behavior to fix this.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.