forked from anish2210/hacktober2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRPS.py
31 lines (23 loc) · 791 Bytes
/
RPS.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
import random
options = ("rock", "paper", "scissors")
running = True
while running:
player = None
computer = random.choice(options)
while player not in options:
player = input("Enter a choice (rock, paper, scissors): ").lower()
print(f"Player: {player}")
print(f"Computer: {computer}")
if player == computer:
print("It's a tie!")
elif player == "rock" and computer == "scissors":
print("You win!")
elif player == "paper" and computer == "rock":
print("You win!")
elif player == "scissors" and computer == "paper":
print("You win!")
else:
print("You lose!")
if not input("Play again? (y/n): ").lower() == "y":
running = False
print("Thanks for playing!")