import random
while True:
score_player = 0
score_computer = 0
while score_computer <= 2 or score_player <= 2:
choices = ['rock', 'scissors', 'paper']
player = None
computer = random.choice(choices)
while player not in choices:
player = input('rock,scissors or paper? : ').lower()
print('computer:', computer)
print('player: ', player)
if player == computer:
print('You are tied!')
elif player == 'rock':
if computer == 'scissors':
score_player += 1
elif computer == 'paper':
score_computer += 1
elif player == 'scissors':
if computer == 'paper':
score_player += 1
elif computer == 'rock':
score_computer += 1
elif player == 'paper':
if computer == 'rock':
score_player += 1
elif computer == 'scissors':
score_computer += 1
print('Score_player : ', score_player)
print('Score_computer', score_computer)
playe_again = input('Do you want to continue? (Yes/No) :').lower()
#while playe_again == 'yes' or 'no':
if playe_again != 'yes':
break
print('I hope you have enjoyed the game!')
Why the conditions inside while loop are not executed correctly.
I want the game to stop when the score of one of them reaches 3,
But it continues until both of them reach 3, and one of them may even become more than 3.