Skip to content

Commit f77a8c0

Browse files
Create play.py
1 parent af813f9 commit f77a8c0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

play.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import random
2+
3+
while True:
4+
5+
user_action = input("Rock, paper, scissors? ")
6+
possible_actions = ["rock", "paper", "scissors"]
7+
computer_action = random.choice(possible_actions)
8+
9+
if user_action == computer_action:
10+
print(f'Both players selected {user_action}. Tie!')
11+
elif user_action.lower() == "rock":
12+
if computer_action.lower() == "scissors":
13+
print("Rock smashes scissors! You win!")
14+
else:
15+
print("Paper covers rock! You lose.")
16+
elif user_action.lower() == "paper":
17+
if computer_action.lower() == "rock":
18+
print("Paper covers rock! You win!")
19+
else:
20+
print("Scissors cuts paper! You lose.")
21+
elif user_action.lower() == "scissors":
22+
if computer_action.lower() == "paper":
23+
print("Scissors cuts paper! You win!")
24+
else:
25+
print("Rock smashes scissors! You lose.")

0 commit comments

Comments
 (0)