import random def getUserChoice(): #Ask the player to press 'a' or 'b', return only a valid response while True: choice = input("Press 'a' or 'b': ").lower() if choice == 'a' or choice == 'b': return choice else: print("Invalid input. Please press 'a' or 'b'.") def getComputerChoice(): #randomly select 'a' or 'b' #check out the useful choice() method in the random library file! return random.choice(['a', 'b']) def updateScore(user, computer): #compares the user choice with the computer choice updates score global score if user == computer: score = score + 1 def evaluateScore(): #evaluate the final score and determine the outcome. if score >= 7: return "Congratulations! You won the game!" else: return "Better luck next time! You lost." def main(): global score score = 0 #Main game loop with 10 rounds for i in range(10): computerChoice = getComputerChoice() userChoice = getUserChoice() updateScore(userChoice, computerChoice) print(f"Computer chose: {computerChoice}") print(f"Current Score: {score}") #grab the evaluation result evaluation = evaluateScore() #display the evaluation print(f"{evaluation}") #call main main()