Python Game Design - Rock Paper Scissors
Python Game Design - Rock Paper Scissors
In this tutorial, you are going to make a “Rock Paper Scissors” game. Below are the game rules:
computer_wins = 0
while True:
player = input("Enter a choice (rock, paper, scissors): ")
choices = ["rock", "paper", "scissors"]
computer = random.choice(choices)
print(f"\nYou chose {player}, computer chose {computer}.")
if player == computer:
print(f"Both players selected {player}. It is a tie!")
elif player == "rock":
if computer == "scissors":
print("Rock smashes scissors. You win!")
player_wins+=1
else:
print("Paper covers rock. You lose.")
computer_wins+=1
elif player == "paper":
if computer == "rock":
print("Paper covers rock. You win!")
player_wins+=1
else:
print("Scissors cuts paper. You lose.")
computer_wins+=1
elif player == "scissors":
if computer == "paper":
print("Scissors cuts paper. You win!")
player_wins+=1
else:
print("Rock smashes scissors. You lose.")
computer_wins+=1
This work is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0