-
Notifications
You must be signed in to change notification settings - Fork 210
/
Rock Paper Scissor.py
67 lines (34 loc) · 1.05 KB
/
Rock Paper Scissor.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
""" Rock Paper Scissors
----------------------------------------
"""
import random
import os
import re
os.system('cls' if os.name=='nt' else 'clear')
while (1 < 2):
print ("\n")
print ("Rock, Paper, Scissors - Shoot!")
userChoice = input("Choose your weapon [R]ock], [P]aper, or [S]cissors: ")
if not re.match("[SsRrPp]", userChoice):
print ("Please choose a letter:")
print ("[R]ock, [S]cissors or [P]aper.")
continue
# Echo the user's choice
print ("You chose: " + userChoice)
choices = ['R', 'P', 'S']
opponentChoice = random.choice(choices)
print ("I chose: " + opponentChoice)
if opponentChoice == str.upper(userChoice):
print ("Tie! ")
#if opponentChoice == str("R") and str.upper(userChoice) == "P"
elif opponentChoice == 'R' and userChoice.upper() == 'S':
print ("Scissors beats rock, I win! ")
continue
elif opponentChoice == 'S' and userChoice.upper() == 'P':
print ("Scissors beats paper! I win! ")
continue
elif opponentChoice == 'P' and userChoice.upper() == 'R':
print ("Paper beat rock, I win!")
continue
else:
print ("You win!")