I need help on my score count for my Rock Paper Scissors game

Question:
How can I fix my score count to where it adds up each time the code loops like a normal score count for a game? Each time I enter a new input and the code loops the score count resets so it is always 1 - 0 or 0 - 1 each time, I want to be able to get the score to stack or add each time the player enters a new input. Thank you for your help!

import random

print("Thank You for choosing to play Rock, Paper, Scissors UPGRADED.          Welcome to Asteroid, Super Blanket, Sword!                          Choose your move!")

while True:
  Player_score=-1
  Computer_score=0
  user = input("Asteroid, Super Blanket, or Sword?") 
  while not user in ["Asteroid","Super Blanket", "Sword"]:
    user = input("Asteroid, Super Blanket, or Sword?")
    if not user in ["Asteroid","Super Blanket", "Sword"]:
      print("Incorrect input, Please choose a correct input")
  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!")  
      Computer_score+=1
    else:
      print("AI chose the Asteroid, The Super Blanket wraps up the Asteroid,       You Win!") 
      Player_score+=1
  elif user == "Sword":
      if computer == "Asteroid":
        print("AI chose the Asteroid, The Asteroid crushes the Sword,  You Lose!")
        Computer_score+=1
      else:
        print("AI chose the Super Blanket, The Sword cuts the Super Blanket, You Win!") 
        Player_score+=1
  elif user == "Asteroid":
    if computer == "Super Blanket":
     print("AI chose the Super Blanket, The Super Blanket wraps up the Asteroid,  You Lose!") 
    Computer_score+=1
  else:
    print("AI chose the Sword, The Asteroid crushes the Sword, You Win!") 
  Player_score+=1
  print("Your score:", Player_score)
  print("Computer score:", Computer_score)

Please :pray: wrap you code in triple backticks!
Like so:
```python
print(“your code here”)
```

Becomes:

print("your code here")
1 Like
import random

print("Thank You for choosing to play Rock, Paper, Scissors UPGRADED.          Welcome to Asteroid, Super Blanket, Sword!                          Choose your move!")

while True:
  Player_score=-1
  Computer_score=0
  user = input("Asteroid, Super Blanket, or Sword?") 
  while not user in ["Asteroid","Super Blanket", "Sword"]:
    user = input("Asteroid, Super Blanket, or Sword?")
    if not user in ["Asteroid","Super Blanket", "Sword"]:
      print("Incorrect input, Please choose a correct input")
  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!")  
      Computer_score+=1
    else:
      print("AI chose the Asteroid, The Super Blanket wraps up the Asteroid,       You Win!") 
      Player_score+=1
  elif user == "Sword":
      if computer == "Asteroid":
        print("AI chose the Asteroid, The Asteroid crushes the Sword,  You Lose!")
        Computer_score+=1
      else:
        print("AI chose the Super Blanket, The Sword cuts the Super Blanket, You Win!") 
        Player_score+=1
  elif user == "Asteroid":
    if computer == "Super Blanket":
     print("AI chose the Super Blanket, The Super Blanket wraps up the Asteroid,  You Lose!") 
    Computer_score+=1
  else:
    print("AI chose the Sword, The Asteroid crushes the Sword, You Win!") 
  Player_score+=1
  print("Your score:", Player_score)
  print("Computer score:", Computer_score)

To fix the score count so that it adds up each time the code loops, you need to move the initialization of Player_score and Computer_score outside the while True loop. Currently, these variables are being reset to their initial values of -1 and 0, respectively, each time the loop restarts. Instead, you want to keep track of the running score, which means initializing them outside the loop so that their values persist between iterations.

Here’s an updated code snippet with the score count fixed:

import random

print("Thank You for choosing to play Rock, Paper, Scissors UPGRADED. Welcome to Asteroid, Super Blanket, Sword! Choose your move!")

Player_score = 0
Computer_score = 0

while True:
    user = input("Asteroid, Super Blanket, or Sword? ")
    while not user in ["Asteroid", "Super Blanket", "Sword"]:
        user = input("Asteroid, Super Blanket, or Sword? ")
        if not user in ["Asteroid", "Super Blanket", "Sword"]:
            print("Incorrect input, Please choose a correct input")

    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!")
            Computer_score += 1
        else:
            print("AI chose the Asteroid, The Super Blanket wraps up the Asteroid, You Win!")
            Player_score += 1
    elif user == "Sword":
        if computer == "Asteroid":
            print("AI chose the Asteroid, The Asteroid crushes the Sword, You Lose!")
            Computer_score += 1
        else:
            print("AI chose the Super Blanket, The Sword cuts the Super Blanket, You Win!")
            Player_score += 1
    elif user == "Asteroid":
        if computer == "Super Blanket":
            print("AI chose the Super Blanket, The Super Blanket wraps up the Asteroid, You Lose!")
            Computer_score += 1
        else:
            print("AI chose the Sword, The Asteroid crushes the Sword, You Win!")
            Player_score += 1

    print("Your score:", Player_score)
    print("Computer score:", Computer_score)

In this updated code, Player_score and Computer_score are initialized before the while True loop, and they are updated within the loop by adding 1 to the corresponding variable when the player or computer wins a round. The scores are then printed at the end of each loop iteration.