-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
30 lines (24 loc) · 780 Bytes
/
index.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
import random
choices = ["rock", "paper", "scissors"]
computer_choice = random.choice(choices)
print("Let's play rock, paper, or scissors")
player_choice = input("Choose rock, paper, or scissors: ").lower()
print(f"Computer chose: {computer_choice}")
# Initialize winner variable
winner = None
# Determine the winner
if (player_choice == "rock" and computer_choice == "scissors") or \
(player_choice == "scissors" and computer_choice == "paper") or \
(player_choice == "paper" and computer_choice == "rock"):
winner = "Player"
elif player_choice == computer_choice:
winner = "Tie"
else:
winner = "Computer"
# Print the result
if winner == "Player":
print("You won!")
elif winner == "Computer":
print("Computer won!")
else:
print("It's a tie!")