How can I add a score count?

Can someone help me on how to add a score count?

This is my code

import random 

print("Thank You for choosing to play Rock, Paper, Scissors UPGRADED.          Welcome to Asteroid, Super Blanket, Sword!                          Choose your move!")
user = input("Asteroid, Super Blanket, or Sword?") 
computer = random.choice(["Asteroid","Super Blanket", "Sword"])


if user == computer: 
     print("You and the AI tied!")
elif user == "Super Blanket":
    if computer == "Sword":
      print("AI chose the Sword, The Sword cuts the Super Blanket, You Lose!")
    else:
      print("AI chose the Asteroid, The Super Blanket wraps up the Asteroid,       You Win!") 
elif user == "Sword":
      if computer == "Asteroid":
        print("AI chose the Asteroid, The Asteroid crushes the Sword,  You Lose!")
      else:
        print("AI chose the Super Blanket, The Sword cuts the Super Blanket, You Win!") 
elif user == "Asteroid":
  if computer == "Super Blanket":
    print("AI chose the Super Blanket, The Super Blanket wraps up the Asteroid, You Lose!")
  else:
    print("AI chose the Sword, The Asteroid crushes the Sword, You Win!")

Create two variables called player_score and computer_score and then update them in the places where each person scores a point. I’m not going to tell you exactly how to do it because you can think through it for yourself, but in every spot where you print something like “You Lose” or “You Win”, then you can update the scores there. Also to keep the game going, wrap it all in a loop to play again, and then you can show the scores at the end like this:

player1_score = 0
player2_score = 0

num_games = 5
for i in range(num_games):
    # your game code here
    ...

print("Your score:", player_score)
print("Computer score:", computer_score)
6 Likes

Thank you so much, I’ve been struggling with how to fix my code with this and i’m happy it finally works. Another thing I did also have trouble with was how to loop my code. I struggle with python because I am currently in AP CSP but we use C++ and I like python better and so I have been trying to learn it which is why I decided to do my final project in python.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.