title: rock paper scissors flow control
body: <p>In the following program for rock paper scissors something is wrong with my loop.  Using the input for set length, the game is played N times for each set.
  For cases in which results are player 2, computer 0; player 0, computer 2; player 2, computer 5; player 0, computer 4; an extra game is added to the set.  I have changed the function many times and can't figure out what is wrong.</p>
  
  <pre><code>def rpsls_play():
      print("Welcome to the Rock-Scissors-Paper-Lizard-Spock game!")
      player_sets=0
      N=int(input("Select set length: "))
      times=0
      player_wins=0
      computer_wins=0
      while times &lt; N:
          times +=1
          print("Now beginning game", times)
          if rpsls_game()==1:
              player_wins +=1
          else:
              computer_wins +=1
          print("Set score: Player", str(player_wins)+", Computer", str(computer_wins))
      else:
          pass
  
      if player_wins==computer_wins:
          while abs(player_wins-computer_wins)&lt;2:         
              times +=1
              print("Now beginning game", times)
              if rpsls_game()==1:
                  player_wins +=1
              else:
                  computer_wins +=1
              print("Set score: Player", str(player_wins)+", Computer", str(computer_wins))
      else:
          pass
  
      if player_wins&gt;computer_wins:
          print("Congratulations! You have won in", times, "games.")
          player_sets +=1
      elif computer_wins&gt;player_wins:
          print("Too bad! You have lost in", times, "games.")
  
      pass
  </code></pre>
  
  <p>thanks for your help</p>