From c354b8b4092d2ef380d4866da3af9144618c9f16 Mon Sep 17 00:00:00 2001 From: Dineth Sadeepa Edirisinghe Date: Thu, 13 Jun 2024 07:34:56 +0000 Subject: [PATCH] chore: Add GitHub Copilot extension to devcontainer.json and implement rock-paper-scissors game in app.py --- .devcontainer/devcontainer.json | 3 ++- app.py | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 74406e3..67433ef 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -16,7 +16,8 @@ "extensions": [ "streetsidesoftware.code-spell-checker", "ms-python.python", - "ms-python.vscode-pylance" + "ms-python.vscode-pylance", + "GitHub.copilot" ] } }, diff --git a/app.py b/app.py index e69de29..72f9220 100644 --- a/app.py +++ b/app.py @@ -0,0 +1,34 @@ +import random + +score = 0 +valid_choices = {"r": "rock", "p": "paper", "s": "scissors"} + +while True: + print("1. Rock (r)\n2. Paper (p)\n3. Scissors (s)") + player_choice = input("Choose your option (r, p, or s): ").lower() + if player_choice not in valid_choices: + print("Invalid choice. Please try again.") + continue + + program_choice = random.choice(list(valid_choices.keys())) + print(f"Program chose {valid_choices[program_choice]}") + + if player_choice == program_choice: + print("It's a tie!") + elif (player_choice == "r" and program_choice == "s") or \ + (player_choice == "p" and program_choice == "r") or \ + (player_choice == "s" and program_choice == "p"): + print("You win!") + score += 1 + else: + print("You lose!") + + + play_again = input("Do you want to play again? (yes/no): ").lower() + while play_again not in ["yes", "no"]: + print("Invalid input. Please enter 'yes' or 'no'.") + play_again = input("Do you want to play again? (yes/no): ").lower() + if play_again == "no": + break + +print(f"Your score: {score}") \ No newline at end of file