Skip to content

Commit 3da2608

Browse files
authored
Create MONTE HALL GAME USING PYTHON
THIS IS THE CODE OF MONTE HALL.THROUGH THIS WE CAN PLAY MONTE HALL IN PROGRAMMING.
1 parent d99f6d6 commit 3da2608

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

MONTE HALL GAME USING PYTHON

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#Monte Mall
2+
import random
3+
doors=[0]*3
4+
goatdoor=[0]*2
5+
swap=0
6+
dont_swap=0
7+
j=0
8+
while(j<5):#you can take any integer value
9+
x=random.randint(0,2)
10+
doors[x]="BMW"
11+
for i in range (0,3):
12+
if(i==x):
13+
continue
14+
else:
15+
doors[i]="GOAT"
16+
goatdoor.append(i)
17+
choice=int(input("enetr your choice"))
18+
door_open=random.choice(goatdoor)
19+
while(door_open==choice):
20+
door_open=random.choice(goatdoor)
21+
ch=input("do you want to swap? y/n::")
22+
if(ch=="y"):
23+
if(doors[choice]=="GOAT"):
24+
print("player wins")
25+
swap=swap+1
26+
else:
27+
print("player lost")
28+
else:
29+
if(doors[choice]=="GOAT"):
30+
print("player lost")
31+
else:
32+
print("player wins")
33+
dont_swap=dont_swap+1
34+
j=j+1
35+
print(swap)
36+
print(dont_swap)

0 commit comments

Comments
 (0)