-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (17 loc) · 890 Bytes
/
Copy pathmain.py
File metadata and controls
27 lines (17 loc) · 890 Bytes
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
import random
def winner(user, cpu):
if (user == "Rock" and cpu == "Paper") or (user == "Paper" and cpu == "Scissor") or (user == "Scissor" and cpu == "Rock"):
return "\nUser : " + user + "\nCPU : " + cpu + "\nWinner : CPU"
elif(cpu == "Rock" and user == "Paper") or (cpu == "Paper" and user == "Scissor") or (cpu == "Scissor" and user == "Rock"):
return "\nUser : " + user + "\nCPU : " + cpu + "\nWinner : User"
elif user == cpu:
return "\nUser : " + user + "\nCPU : " + cpu + "\nWinner : Draw"
options = ["Rock", "Paper", "Scissor"]
while True:
UI = input("\nEnter Your Choice (rock, paper, scissor) : ").title()
if UI not in options:
continue
print(winner(UI, random.choice(options)))
YN = input("\nPlay Again? (yes/no) : ").lower()
if YN == "no":
break