import random def play_game(): choices = ["rock", "paper", "scissors"] player_score = 0 computer_score = 0 print("=== Welcome to Rock, Paper, Scissors! ===") print("Type 'quit' at any time to exit the game.\n") while True: # Get and clean user input user_choice = ( input("Enter your choice (rock, paper, scissors): ") .strip() .lower() ) if user_choice == "quit": break if user_choice not in choices: print("Invalid choice! Please try again.\n") continue # Get computer selection computer_choice = random.choice(choices) print(f"You chose: {user_choice}") print(f"Computer chose: {computer_choice}") # Determine the winner if user_choice == computer_choice: print("It's a tie!\n") elif ( (user_choice == "rock" and computer_choice == "scissors") or (user_choice == "paper" and computer_choice == "rock") or (user_choice == "scissors" and computer_choice == "paper") ): print("🎉 You win this round!\n") player_score += 1 else: print("😢 Computer wins this round!\n") computer_score += 1 # Display current standings print(f"Scoreboard -> You: {player_score} | Computer: {computer_score}") print("-" * 40 + "\n") print("\n=== Game Over ===") print(f"Final Score -> You: {player_score} | Computer: {computer_score}") print("Thanks for playing!") if __name__ == "__main__": play_game()