import random # Function to get the computer's choice def get_computer_choice(): return random.choice(['rock', 'paper', 'scissors']) # Function to determine the winner of a single round def determine_winner(player_choice, computer_choice): if player_choice == computer_choice: return 'tie' elif (player_choice == 'rock' and computer_choice == 'scissors') or \ (player_choice == 'paper' and computer_choice == 'rock') or \ (player_choice == 'scissors' and computer_choice == 'paper'): return 'player' else: return 'computer' # Function to play a single round def play_round(): player_choice = input("Choose rock, paper, or scissors: ").lower() while player_choice not in ['rock', 'paper', 'scissors']: print("Invalid choice. Please choose rock, paper, or scissors.") player_choice = input("Choose again: ").lower() computer_choice = get_computer_choice() print(f"Computer chooses {computer_choice}.") winner = determine_winner(player_choice, computer_choice) if winner == 'tie': print("It's a tie!") elif winner == 'player': print("You win!") else: print("Computer wins!") return winner # Main game function def play_game(): player_score = 0 computer_score = 0 print("Let's play Rock, Paper, Scissors!") for _ in range(3): print(f"\nRound {_ + 1}:") winner = play_round() if winner == 'player': player_score += 1 elif winner == 'computer': computer_score += 1 print("\nGame Over!") if player_score > computer_score: print("Winner Winner delicious chicken dinner!") elif player_score < computer_score: print("You SUCK!") else: print("It's a tie!") # Start the game if __name__ == "__main__": play_game()