Skip to content

Instantly share code, notes, and snippets.

@smertelny
Created February 9, 2018 07:53
Show Gist options
  • Select an option

  • Save smertelny/3fef402fb4072892bdcda80c4cd82ea9 to your computer and use it in GitHub Desktop.

Select an option

Save smertelny/3fef402fb4072892bdcda80c4cd82ea9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from random import randint
counter = {
'wins': 0,
'games': 0
}
print('Hello! I wanna play a little game')
while True:
doors = [None, None, None]
win_door = randint(0, 2)
doors[win_door] = 'Prize!!!'
usr_input = int(input("Pick your door"))
while True:
open_door = randint(0,2)
if not doors[open_door] and open_door != usr_input:
break
print(f'We opened for you door number {open_door}')
usr_input = int(input("Choose your door again"))
if doors[usr_input]:
print('You won!')
counter['wins'] += 1
else:
print('You Loose!!!')
counter['games'] += 1
exit_input = input('Another game?')
if exit_input == 'exit':
print("Your rating is {}".format(counter['wins']/counter['games']))
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment