DEV Community

T-Roy
T-Roy

Posted on

My_First_Project

import random

def play_game():
print("Welcome to Rock, Paper, Scissors!")
print("Type 'rock', 'paper', or 'scissors' to play. Type 'quit' to exit.")

choices = ["rock", "paper", "scissors"]

while True:
    user_choice = input("Your choice: ").lower()
    if user_choice == "quit":
        print("Thanks for playing! Goodbye!")
        break

    if user_choice not in choices:
        print("Invalid choice. Please try again.")
        continue

    computer_choice = random.choice(choices)
    print(f"Computer chose: {computer_choice}")

    if user_choice == computer_choice:
        print("It's a tie!")
    elif (user_choice == "rock" and computer_choice == "scissors") or \
         (user_choice == "paper" and computer_choice == "rock") or \
         (user_choice == "scissors" and computer_choice == "paper"):
        print("You win!")
    else:
        print("You lose!")
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
nathan_tarbert profile image
Nathan Tarbert

this kinda takes me back tbh, first projects always hit different - you think getting the basics down early makes stuff easier in the long run or nah?

Collapse
 
troy_25 profile image
T-Roy

I think so