Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"extensions": [
"streetsidesoftware.code-spell-checker",
"ms-python.python",
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"GitHub.copilot"
]
}
},
Expand Down
34 changes: 34 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -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}")