title: How to debug my Python dice game?
body: <p>So I recently posted my code for a simple dice program I'm having trouble with. It is supposed to randomly generate 5 numbers in an array, then check if there are any matching values, if there are, it adds to MATCH, so once it's done checking, MATCH+1 is how many 'of a kind' there are(match=1 means two of a kind, match=2 means three of a kind etc.)</p>
  
  <p>It randomly generates and then displays the numbers correctly, and the program seems to check without errors except when the last two playerDice elements match, then it throws an out of bounds error, Why is it doing that? Also it never actually displays the last print line with how many of a kind there are, even when it runs error free, Why is that?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import random
  playerDice = [random.randint(1,6),random.randint(1,6),random.randint(1,6),random.randint(1,6),random.randint(1,6)]
  compDice = [random.randint(1,6),random.randint(1,6),random.randint(1,6),random.randint(1,6),random.randint(1,6)]
  match = 0
  compmatch = 0
  
  #print player dice
  print("You rolled: ",end=" ")
  a = 0
  while a &lt; len(playerDice):
          print(str(playerDice[a]) + ", ",end=" ")
          a = a + 1
  
  #player check matches
  i = 0
  while i &lt; len(playerDice):
  
          j = i + 1
          if playerDice[i] == playerDice[j]:
                  match = match + 1
  
          while playerDice[i] != playerDice[j]:
                  j = j + 1
                  if playerDice[i] == playerDice[j]:
                          match = match + 1
  
  i = i + 1
  
  print("Player has: " + str(match + 1) + " of a kind.")
  </code></pre>