import random
print("Rock, Paper, Scissors")
# Possible choices
choices = ["ROCK", "PAPER", "SCISSORS"]
# User choice
user_choice = input("Enter your choice: Rock, Paper, Scissors? ").upper()
# Check if user input is valid
if user_choice not in choices:
print("Invalid choice. You lost.")
else:
# Computer choice
computer_choice = random.choice(choices)
# Compare user choice and computer choice to determine winner
if user_choice == computer_choice:
print(f"It's a tie! Both chose {user_choice}.")
elif user_choice == "ROCK" and computer_choice == "SCISSORS":
print(f"You won! {user_choice} beats {computer_choice}.")
elif user_choice == "PAPER" and computer_choice == "ROCK":
print(f"You won! {user_choice} beats {computer_choice}.")
elif user_choice == "SCISSORS" and computer_choice == "PAPER":
print(f"You won! {user_choice} beats {computer_choice}.")
else:
print(f"You lost. {computer_choice} beats {user_choice}.")
Comments
Post a Comment