-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
27 lines (22 loc) Β· 780 Bytes
/
Copy pathgame.py
File metadata and controls
27 lines (22 loc) Β· 780 Bytes
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
import random
# Options for the game
choices = ["rock", "paper", "scissors"]
print("π Welcome to Rock, Paper, Scissors!")
while True:
user = input("Type rock, paper, or scissors (or 'q' to quit): ").lower()
if user == 'q':
print("Thanks for playing! π")
break
if user not in choices:
print("β Not a valid choice. Try again!")
continue
computer = random.choice(choices)
print(f"π§ Computer chose: {computer}")
if user == computer:
print("π€ It's a tie!")
elif (user == "rock" and computer == "scissors") or \
(user == "scissors" and computer == "paper") or \
(user == "paper" and computer == "rock"):
print("β
You win!")
else:
print("π» Computer wins!")