-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (30 loc) · 1.13 KB
/
main.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
import random
objects = {'R': 'Rock', 'P': 'Paper', 'S': 'Scissors'}
options = [*objects.keys()]
while True:
user_option = input('Choose one: (R)ock, (P)aper or (S)cissors >> ').upper()
if user_option not in options:
print('Error: Invalid option')
else:
cpu_option = random.choice(options)
print(f"Player ({objects[user_option]}) : CPU ({objects[cpu_option]})")
if user_option == cpu_option:
print(f"You both chose {objects[user_option]}. It's a tie.")
elif user_option == "R":
if cpu_option == "S":
print("Rock smashes scissors! You win!")
else:
print("Paper covers rock. You lose.")
break
elif user_option == "P":
if cpu_option == "R":
print("Paper covers rock! You win!")
else:
print("Scissors cuts paper. You lose.")
break
elif user_option == "S":
if cpu_option == "P":
print("Scissors cuts paper! You win!")
else:
print("Rock smashes scissors. You lose.")
break