Create Rock Paper Scissors Game

Rock, Paper, Scissors is a hand game played between two players. Each player simultaneously forms one of three shapes using their hand: rock, paper, or scissors. The winner is determined based on the choices made.

import random

choices = ["rock", "paper", "scissors"]

print("Let's play Rock, Paper, Scissors!")

while True:

player_choice = input("Enter your choice (rock/paper/scissors): ").lower()

if player_choice not in choices:

print("Invalid choice. Please try again.")

continue

computer_choice = random.choice(choices)

print("Computer chose:", computer_choice)

if player_choice == computer_choice:

print("It's a 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")

):

print("Congratulations! You win!")

else:

print("You lose!")

play_again = input("Do you want to play again? (yes/no): ").lower()

if play_again != "yes":

break

Related Stories