forked from nishant-Tiwari24/python-foundation-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonteHall.py
More file actions
33 lines (30 loc) · 691 Bytes
/
MonteHall.py
File metadata and controls
33 lines (30 loc) · 691 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
import random
doors = [0]*3
goatDoor = [0]*2
swapWins = 0
noSwapWins = 0
price = random.randint(0,2)
doors[price] = 'price'
for i in range(0,2):
if(i==price):
continue
else:
doors[i] = 'Goat'
goatDoor.append(i)
c = int(input("Enter your choice"))
doorOpen = random.choice(goatDoor)
while(doorOpen==c):
doorOpen = random.choice(goatDoor)
ch = input("Do you want to swap? y/n")
if(ch=='y'):
if(doors[c]=='Goat'):
print('Player wins')
swapWins = swapWins + 1
else:
print('Player lost')
else:
if(doors[c]=='Goat'):
print('Player lost')
else:
print('player wins')
noSwapWins = noSwapWins + 1