-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonte_Hall.py
More file actions
45 lines (36 loc) · 908 Bytes
/
Copy pathMonte_Hall.py
File metadata and controls
45 lines (36 loc) · 908 Bytes
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
import random
doors=[0]*3
goatdoor=[0]*2
swap=0 #swap wins
dont_swap=0 #dont swap wins
j=0
while(j<10):
x=random.randint(0,2)
doors[x]="BMW"
for i in range(0,3):
if(i==x):
continue
else:
doors[i]="Goat"
goatdoor.append(i)
choice= int(input("Enter your choice"))
door_open=random.choice(goatdoor)
while(door_open==choice):
door_open=random.choice(goatdoor)
ch=input("Do you want to swap? y/n")
if(ch=='y' or ch=='Y'):
if(doors[choice]=='Goat'):
print("Player wins")
swap=swap+1
else:
print("Player lost")
else:
if(doors[choice]=='Goat'):
print("Player Lost")
else:
print("Player wins")
dont_swap=dont_swap+1
j=j+1
print("After 9 games we get")
print(swap)
print(dont_swap)