-
Notifications
You must be signed in to change notification settings - Fork 0
/
8_rock_paper_scissors.py
43 lines (40 loc) · 1.39 KB
/
8_rock_paper_scissors.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
# Rock Paper Scissors
# Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input),
# compare them, print out a message of congratulations to the winner, and ask if the players
# want to start a new game)
# Remember the rules:
# Rock beats scissors
# Scissors beats paper
# Paper beats rock
import random
# 1st method
while True:
try:
player0 = int(input('Please select [0 - rock, 1, scissors, '
'2 - paper, -1 - exit and enter a number: '))
player1 = int(random.randint(0, 2))
print('Mark chose: {}'.format(player1))
if player0 == 0 and player1 == 0:
print('Again')
elif player0 == 0 and player1 == 1:
print('You win!')
elif player0 == 0 and player1 == 2:
print('You lose')
elif player0 == 1 and player1 == 1:
print('Again')
elif player0 == 1 and player1 == 0:
print('You lose')
elif player0 == 1 and player1 == 2:
print('You win!')
elif player0 == 2 and player1 == 2:
print('Again')
elif player0 == 2 and player1 == 0:
print('You win!')
elif player0 == 2 and player1 == 1:
print('You lose')
elif player0 == -1 or player1 == -1:
break
else:
print('Wrong number')
except ValueError:
print('Wrong value')