diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 74406e3..2e9a107 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" ] } }, @@ -35,4 +36,4 @@ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" -} \ No newline at end of file +} diff --git a/app.py b/app.py index e69de29..c28b132 100644 --- a/app.py +++ b/app.py @@ -0,0 +1,47 @@ +# Player chooses rock, paper, or scissors +# Check if the player's choice is valid and inform if not +# Randomly choose an option for the computer +# Determine the winner of the round based on choices +# Display the result and update the player's score +# Ask if the player wants to play again +# End the game and display the final score + +import random + +valid_choices = ["rock", "paper", "scissors"] +player_score = 0 + +def play_game(): + global player_score + player_choice = input("Choose rock, paper, or scissors: ") + + if player_choice not in valid_choices: + print("Invalid choice. Please choose rock, paper, or scissors.") + play_again = input("Do you want to play again? (yes/no): ") + if play_again.lower() == "yes": + play_game() + else: + print(f"Game over. Final score: {player_score}") + else: + computer_choice = random.choice(valid_choices) + + if player_choice == computer_choice: + result = "It's a tie!" + elif (player_choice == "rock" and computer_choice == "scissors") or (player_choice == "paper" and computer_choice == "rock") or (player_choice == "scissors" and computer_choice == "paper"): + result = "You win!" + player_score += 1 + else: + result = "Computer wins!" + + print(f"Player chose: {player_choice}") + print(f"Computer chose: {computer_choice}") + print(result) + + play_again = input("Do you want to play again? (yes/no): ") + if play_again.lower() == "yes": + play_game() + else: + print(f"Game over. Final score: {player_score}") + +play_game() +