-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonte Hall Game.py
43 lines (37 loc) · 1.14 KB
/
Monte Hall Game.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
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 30 09:08:22 2023
@author: HP
"""
#Monte Hall Game
import random as r
while True:
doors=[0,0,0]
pos1=r.randint(0,2)
doors[pos1]='Treasure'
inp1=int(input("Enter the number of door with treasure(1/2/3):"))
while True:
pos2=r.randint(0,2)
if pos2!=inp1 and doors[pos2]==0:
print("Opened door",pos2+1,"and found it empty")
ch=input("Wanna swap(Y/N)?")
if ch.upper()=="Y":
for i in range(3):
if i!=inp1 and i!=pos2:
inp2=i
if doors[inp2-1]=='Treasure':
print('You found the Treasure.')
break
else:
print("Treasure was in door",pos1+1)
break
else:
if doors[inp1-1]=='Treasure':
print('You found the Treasure in box',pos1+1)
break
else:
print("Treasure was in door",pos1+1)
break
choice=input("Wanna Continue(Y/N)?")
if choice.upper()!='Y':
break