じゃんけんゲームの実装(簡単)
実装例
rock_paper_scissors.py
import random
options = ["rock", "paper", "scissors"]
while True:
computer_choice = random.choice(options)
player_choice = input("Rock, paper, or scissors? ").lower()
if player_choice == "quit":
break
elif player_choice in options:
if player_choice == computer_choice:
print("Tie!")
elif player_choice == "rock" and computer_choice == "scissors":
print("You win!")
elif player_choice == "paper" and computer_choice == "rock":
print("You win!")
elif player_choice == "scissors" and computer_choice == "paper":
print("You win!")
else:
print("Computer wins!")
else:
print("Invalid option.")