mercredi 7 octobre 2020

How do you exclude one item from a list to the random operation? [closed]

How do i exclude one item from a list to choose randomly from. The context is that I have Monty Halls doors list of doors which have each value False or True and i have to choose one door at random other than the door with the value True, if the chosen door is the True door. AKA the car door.

def remove_wrong_doors(chosen_door, doors):
    if doors[chosen_door - 1]:
        return doors[random.randint(0, len(doors))]

    return doors.index(True) + 1



Aucun commentaire:

Enregistrer un commentaire