Hihi, I have successfully made rock paper scissors in python but I’m having trouble when it comes to actually having the player play a best-of-7 game. I would like for the game to run 7 times, count the scores (i.e. if the computer won, the player won or the game was a tie) and then tell those scores to the player at the end. The below code is just the game itself without any while loops to indicate turns since I couldn’t get the turns system working. Whenever I did get it correctly working, it would always instead of being a random choice (rock, paper or scissors) just choose whatever it chose first 7 times.
import random
choices = ["Rock", "Scissors", "Paper"]
choice = random.choice(choices)
# should i put a while loop in game() or outside? neither make the choice random, it's always whatever the computer chose first
def game():
prompt = input("Rock, paper or scissors?: ").title()
match prompt:
case "Rock":
if choice == "Paper":
print("Paper, I win!")
if choice == "Scissors":
print("Scissors, you win!")
case "Paper":
if choice == "Scissors":
print("Scissors, I win!")
if choice == "Rock":
print("Rock, you win!")
case "Scissors":
if choice == "Rock":
print("Rock, I win!")
if choice == "Paper":
print("Paper, you win!")
if choice == prompt:
print(f"{choice}, Tie!")
game()