import random def play_game(): print("Welcome to Rock, Paper, Scissors!") print("Type 'rock', 'paper', or 'scissors' to play.") print("Type 'exit' to quit the game.") choices = ['rock', 'paper', 'scissors'] while True: user_choice = input("Enter your choice: ").lower() if user_choice == 'exit': print("Thanks for playing! Goodbye!") break elif user_choice not in choices: print("Invalid choice. Please type 'rock', 'paper', or 'scissors'.") continue # Randomly select the computer's choice computer_choice = random.choice(choices) print(f"The computer chose: {computer_choice}") # Determine the winner if user_choice == computer_choice: print("It's a tie!") elif (user_choice == 'rock' and computer_choice == 'scissors') or \ (user_choice == 'scissors' and computer_choice == 'paper') or \ (user_choice == 'paper' and computer_choice == 'rock'): print("You win!") else: print("You lose!") # Ask if the player wants to play again play_again = input("Do you want to play again? (yes/no): ").lower() if play_again != 'yes': print("Thanks for playing! Goodbye!") break if __name__ == "__main__": play_game()