  @ebest/

# Monty hall ## No description

Files
• main.py
main.py
```1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
```
```from random import randint
from time import sleep
cars = 0
goats = 0
chosen = 0
while True:
a = [1,2,3]
cdoor = randint(0, 2)
doors = [0,0,0]
doors[cdoor] = 1
while chosen not in ["1","2","3", "r"]:
chosen = input("door 1, 2, or 3 ")
if chosen == "r":
chosen = randint(1,3)
chosen = int(chosen) - 1
doorsn = []
for d in range(0, len(doors)):
if d != chosen:
if doors[d] == 0:
doorsn.append(d)
if len(doorsn) > 1:
door = randint(0,1)
door = doorsn[door]
print("door " + str(door + 1) + " has a goat!")
else:
door = str(doorsn + 1)
print("door " + door + " has a goat!")
sorn = input("Switch or not? (Y or N) ")
if sorn == "N" or sorn == "n":
if doors[chosen] == 1:
print("Here's a car!")
cars += 1
else:
print("Here's a goat!")
goats += 1
elif sorn == "Y" or sorn == "y":
for n in [1,2,3]:
if n - 1 == chosen or n == int(door):
a.pop(a.index(n))
chosen = a - 1
if doors[chosen] == 1:
print("Here's a car!")
cars += 1
else:
print("Here's a goat!")
goats += 1
sleep(1)
print("\n" * 45)
print("You have " + str(goats) + " goat(s) and " + str(cars) + " car(s)!")

```