I am trying my hand a developing the code for this game.
After deciding how many rounds (3, 5 or 7), I ask for input on which move the user will do. After comparison with the ai's choice, I want the score to be displayed each round.
The way I want to display the score is as a list type : score = [ai_score, player_score]. However, whenever I try to increment a player's score, when I call print (score) the list is not updated with the values. Each round the print returns [0, 0]
My question is : Can you put variables in a list and then increment those variables?
Thank you.
Please see code :
import random
ai_score, player_score=0,0
score = [ai_score, player_score]
game = ['R','P','S']
rounds = int(input('Welcome to the Rock Paper Scissor game. Before starting, how many rounds would you like to choose : 3, 5 or 7?'))
for round in range(rounds):
player_choice = input('Please choose your move : R for rock, P for paper, S for scissors :')
ai_choice = random.choice(game)
if player_choice in game:
if player_choice == ai_choice:
print("it's a draw")
elif player_choice == 'R':
if ai_choice == 'S':
player_score += 1
print('You win the round!')
elif ai_choice == 'P':
ai_score += 1
print("You loose this round")
elif player_choice == 'P':
if ai_choice == 'R':
player_score += 1
print('You win the round!')
elif ai_choice == 'S':
ai_score += 1
print("You loose this round")
elif player_choice == 'S':
if ai_choice == 'P':
player_score += 1
print('You win the round!')
elif ai_choice == 'R':
ai_score += 1
print("You loose this round")
print("This is round %d" % round)
print("The score is %s" % score)
print(score)
else:
print('Please enter one of the 3 choices')