-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRock paper Scissors.py
More file actions
45 lines (36 loc) · 1.47 KB
/
Rock paper Scissors.py
File metadata and controls
45 lines (36 loc) · 1.47 KB
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
import random
while True:
game_options = ["Rock", "Paper", "Scissors"]
r = "Rock"
p = "Paper"
s = "Scissors"
user_choice = input("What do you choose? Type R for Rock, P for Paper or S for Scissors.\n").lower()
while user_choice != "r" and user_choice != "p" and user_choice != "s":
print("Invalid! Input is not amongst our options")
user_choice = input("What do you choose? Type R for Rock, P for Paper or S for Scissors.\n").lower()
computer_choice = random.choice(game_options)
if user_choice == "r":
user_choice = game_options[0]
print(f"Player({game_options[0]}): CPU ({computer_choice})")
elif user_choice == "p":
user_choice = game_options[1]
print(f"Player({game_options[1]}): CPU ({computer_choice})")
elif user_choice == "s":
user_choice = game_options[2]
print(f"Player({game_options[2]}): CPU ({computer_choice})")
if user_choice == computer_choice:
print("It's a tie")
continue
if user_choice == "Rock" and computer_choice == "Paper":
print("CPU wins!")
elif computer_choice == "Rock" and user_choice == "Paper":
print("You win")
elif user_choice == "Rock" and computer_choice == "Scissors":
print("You win!")
elif user_choice == "Scissors" and computer_choice == "Rock":
print("CPU wins!")
elif user_choice == "Scissors" and computer_choice == "Paper":
print("You win!")
elif computer_choice == "Paper" and user_choice == "Scissors":
print("CPU wins")
break