Rock Scissor Paper Code
Rock Scissor Paper Code
while True:
print("Welcome to Rock, Paper, Scissors!")
player_choice = input("Choose your weapon:\n1. Rock\n2. Paper\n3. Scissors\
nEnter your choice (1-3): ")
# Input validation
if player_choice not in ["1", "2", "3"]:
print("Invalid choice. Please enter a number between 1 and 3.\n")
continue
player_choice = int(player_choice)
# Computer's choice
computer_choice = random.randint(1, 3)
# Display choices
print("\nYou chose:", end=" ")
if player_choice == 1:
print("Rock")
elif player_choice == 2:
print("Paper")
else:
print("Scissors")
# Play again?
play_again = input("Play again? (y/n): ")
if play_again.lower() != "y":
break