Jun-04-2020, 01:49 AM
import random print("Welcome to ROCK PAPER SCISSORS!") selecter = random.randint(1, 3) computer_choice = "" computer_score = 0 player_score = 0 computer_choice_history = [] playing = True while_counter = 0 while playing: while_counter += 1 if computer_score or player_score == 3: playing = False if while_counter > 2: if computer_choice_history[0] == computer_choice_history[1]: selecter = random.randint(1, 3) # computer and player choices player_choice = input("\nchoose rock, paper or scissors:\n") if selecter == 1: computer_choice = "rock" elif selecter == 2: computer_choice = "paper" elif selecter == 3: computer_choice = "scissors" print(computer_choice) computer_choice_history.append(selecter) # computer wins round if computer_choice == "rock" and player_choice == "scissors": computer_score += 1 print("computer score - " + str(computer_score)) print("your score - " + str(player_score)) elif computer_choice == "scissors" and player_choice == "paper": computer_score += 1 print("computer score - " + str(computer_score)) print("your score - " + str(player_score)) elif computer_choice == "paper" and player_choice == "rock": computer_score += 1 print("computer score - " + str(computer_score)) print("your score - " + str(player_score)) # If both chose the same if computer_choice == player_choice: print("Tie") # player wins round elif player_choice == "rock" and computer_choice == "scissors": player_score += 1 print("your score - " + str(player_score)) print("computer score - " + str(computer_score)) elif player_choice == "scissors" and computer_choice == "paper": player_score += 1 print("your score - " + str(player_score)) print("computer score - " + str(computer_score)) elif player_choice == "paper" and computer_choice == "rock": player_score += 1 print("your score - " + str(player_score)) print("computer score - " + str(computer_score)) if computer_score == 3: print("\nComputer wins, YOU LOSE") elif player_score == 3: print("\nCongrats You Win!") satisfaction = input("\nare you satisfied?\n")Hi,
The above code is meant to repeat until either the 'computer_score' or the 'player_score' are equal to 3, but for some reason the while loop ends randomly and I'm not sure what is causing it.
Any suggestions?