0% found this document useful (0 votes)
13 views2 pages

Python Rock Paper Scissors Game Code

This document contains a Python script for a simple rock-paper-scissors game. The user inputs their choice, and the computer randomly selects one of the three options. The game evaluates the choices and declares a winner or a tie, with an option to play again.

Uploaded by

prakriti.patel12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Python Rock Paper Scissors Game Code

This document contains a Python script for a simple rock-paper-scissors game. The user inputs their choice, and the computer randomly selects one of the three options. The game evaluates the choices and declares a winner or a tie, with an option to play again.

Uploaded by

prakriti.patel12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

-CODE-

import random

while True:
user_action = input("Enter a choice (rock, paper, scissors): ")
possible_actions = ["rock", "paper", "scissors"]
computer_action = [Link](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.")
play_again = input("Play again? (y/n): ")
if play_again.lower() != "y":
break

You might also like