Simple text-based game: **”Rock, Paper, Scissors”**.
### Game: **Rock, Paper, Scissors**
This is the classic game where the player plays against the computer.
```python
import random
def rock_paper_scissors():
options = [“rock”, “paper”, “scissors”]
print(“Welcome to ‘Rock, Paper, Scissors’!”)
print(“Type ‘rock’, ‘paper’, or ‘scissors’ to play. Type ‘exit’ to quit.”)
while True:
# Ask the player to choose an option
player_choice = input(“Enter your choice: “).lower()
# If the player wants to exit
if player_choice == “exit”:
print(“Thanks for playing! Goodbye.”)
break
# If the player’s choice is not valid
if player_choice not in options:
print(“Invalid choice. Please try again.”)
continue
# The computer randomly selects an option
computer_choice = random.choice(options)
print(f”The computer chose: {computer_choice}”)
# Determine the winner
if player_choice == computer_choice:
print(“It’s a tie!”)
elif (player_choice == “rock” and computer_choice == “scissors”) or \
(player_choice == “scissors” and computer_choice == “paper”) or \
(player_choice == “paper” and computer_choice == “rock”):
print(“You win!”)
else:
print(“You lose!”)
# Start the game
rock_paper_scissors()
```
### How the Game Works:
1. The player chooses between “rock”, “paper”, or “scissors”.
2. The computer randomly selects one of these options.
3. The game compares the player’s choice with the computer’s choice and determines the winner based on the rules:
— Rock beats Scissors
— Scissors beat Paper
— Paper beats Rock
4. The game continues until the player types “exit”.
### Example Output:
```
Welcome to ‘Rock, Paper, Scissors’!
Type ‘rock’, ‘paper’, or ‘scissors’ to play. Type ‘exit’ to quit.
Enter your choice: rock
The computer chose: paper
You lose!
Enter your choice: scissors
The computer chose: paper
You win!
Enter your choice: exit
Thanks for playing! Goodbye.
```
This is such a great memory! I remember learning this during a coding bootcamp years ago. Of course, I don’t remember it well now because I didn’t continue coding afterward, as my major wasn’t related to programming and I couldn’t find a job after the bootcamp. However, I’ve decided to start learning again from the basics, just for fun.