-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP-S-R.py
65 lines (58 loc) · 1.83 KB
/
P-S-R.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
#Game:Rock‐Paper‐Scissors
#==================================================================
myformat="%-15s%-15s%-15s"
print(myformat%("Player A","Player B","Result"))
print(myformat%("Rock","Rock","Tie"))
print(myformat%("Rock","Paper","Player B"))
print(myformat%("Rock","Scissors","Player A"))
print(myformat%("Paper","Rock","Player A"))
print(myformat%("Paper","Paper","Tie"))
print(myformat%("Paper","Scissors","Player B"))
print(myformat%("Scissors","Rock","Player B"))
print(myformat%("Scissors","Paper","Player A"))
print(myformat%("Scissors","Scissors","Tie"))
while True:
print("Please enter rock or paper or scissors or bye.")
a=input("Player A? ")
#Determine if the input is legal
while a!="paper" and a!="scissors" and a!="rock" and a!="bye":
print("Invalid input. Please enter again.")
a=input("Player A? ")
if a=="bye":
break
b=input("Player B? ")
#Determine if the input is legal
while b!="paper" and b!="scissors" and b!="rock" and b!="bye":
print("Invalid input. Please enter again.")
b=input("Player B? ")
if b=="bye":
break
#Determine who wins
if a=="rock" and b=="rock":
print(a,b)
print("Outcome:Tie")
elif a=="rock" and b=="paper":
print(a,b)
print("Outcome:Player B wins!")
elif a=="rock" and b=="scissors":
print(a,b)
print("Outcome:Player A wins!")
elif a=="paper" and b=="rock":
print(a,b)
print("Outcome:Player A wins!")
elif a=="paper" and b=="paper":
print(a,b)
print("Outcome:Tie")
elif a=="paper" and b=="scissors":
print(a,b)
print("Outcome:Player B wins!")
elif a=="scissors" and b=="rock":
print(a,b)
print("Outcome:Player B wins!")
elif a=="scissors" and b=="paper":
print(a,b)
print("Outcome:Player A wins!")
elif a=="scissors" and b=="scissors":
print(a,b)
print("Outcome:Tie")
print()