title: Why aren't the conditions within my while loop working in python?
body: <p>I have tried to create a programme where you can play Rock Paper Scissors agains the computer. I managed to make it at a basic level but I wanted to upgrade the game so you can keep track of how many wins the user and computer has in a number of total games the user decides.</p>
  <p>I have used a while loop that will execute and continue the game as long as the total games played (excluding ties) doesn't exceed the 'best_of&quot; games the user decides at the beginning. But it isn't working. For example, if I decide I want to play best_of 3 games with computer, and I win 3 times, it will still ask me to input rock paper or scissors.</p>
  <pre><code>import random
  
  # keep track of who wins throughout the game
  user_wins = 0
  computer_wins = 0
  
  # list of possible inputs to play the game
  options = [&quot;r&quot;, &quot;p&quot;, &quot;s&quot;]
  
  #user chooses how many games to play on aggregate
  best_of = int(input('Best out of: '))
  
  print(best_of)
  
  # define a function that takes in two players as arguments
  # and returns True if player wins based on the standard rules
  # of rock paper scissors
  def is_winner(player, opponent):
      if (player == 'r' and opponent == 's') or \
      (player == 'p' and opponent == 'r') or \
      (player == 's' and opponent == 'p'):
          return True
      
  # game continues while the number of games(not inclunding ties) 
  # does not exceed best_of
  while (user_wins + computer_wins) &lt;= best_of:
      user_input = input(&quot;&quot;&quot;
      What do you play?
      'r' for rock,
      'p' for paper,
      's' for scissors
      Press 'q' to quit: &quot;&quot;&quot;).lower()
      
      # loop breaks if user enters 'q'
      if user_input == &quot;q&quot;:
          break
      
      # if user_input is not 'r', 'p', or 's', then has to try again
      if user_input not in options:
          continue
      
      #computer selects 'r', 'p' or 's' randomly
      computer_pick = random.choice(options)
  
      #print each players input
      print(&quot;You picked: &quot;, user_input)
      print(&quot;Computer picked: &quot;, computer_pick)
  
      # if inputs are the same then, game is tie and goes through loop again
      if user_input == computer_pick:
          print('It\'s a tie!')
          continue
  
      # if the player is winner, print a win message and add 1 to the user_wins variable
      elif is_winner(user_input, computer_pick):
          print('You won!')
          user_wins += 1
  
      # by default, if player doesnt win AND not a tie, the computer wins
      # so prints 'you lost' and add 1 to computer_wins
      else:
          print(&quot;You lost!&quot;)
          computer_wins += 1
  
  #print final score once game is finshed
  print(&quot;You won &quot;, user_wins, &quot; times.&quot;)
  print(&quot;The computer won &quot;, computer_wins, &quot; times.&quot;)
  print(&quot;Goodbye!&quot;) 
  </code></pre>