create a rock paper scissors game in python
You may have played rock paper scissors before. Maybe you’ve used it to decide who pays for dinner or who gets first choice of players for a team.
If you’re unfamiliar, rock paper scissors is a hand game for two or more players. Participants say “rock, paper, scissors” and then simultaneously form their hands into the shape of a rock (a fist), a piece of paper (palm facing downward), or a pair of scissors (two fingers extended). The rules are straightforward:
Rock smashes scissors. Paper covers rock. Scissors cut paper.
Now that you have the rules down, you can start thinking about how they might translate to Python code
import random
user_action = input("Enter a choice (rock, paper, scissors): ") possible_actions = ["rock", "paper", "scissors"] computer_action = random.choice(possible_actions) print(f"\nYou chose {user_action}, computer chose {computer_action}.\n")
if user_action == computer_action: print(f"Both players selected {user_action}. It's a tie!") elif user_action == "rock": if computer_action == "scissors": print("Rock smashes scissors! You win!") else: print("Paper covers rock! You lose.") elif user_action == "paper": if computer_action == "rock": print("Paper covers rock! You win!") else: print("Scissors cuts paper! You lose.") elif user_action == "scissors": if computer_action == "paper": print("Scissors cuts paper! You win!") else: print("Rock smashes scissors! You lose.")
i would suggest this repository's method of doing this tbh,https://github.com/superking816pro/rock-paper-sissor-spock