title: How to debug the Python error "IndexError: list index out of range, line X"?
body: <p>I'm new to programming. For an academic assignment we are to make a game that rolls 5 random dice, displays them, and then checks each one against the other to see if they match, then it adds up how many 'of a kind' the player and computer has and whoever has more wins.  I am currently just trying to get the player side to work, it generates the numbers and then displays them but during the checking I get an index out of range error when it checks the outer loop die to the inner loop dice</p>
  
  <p>I've been racking my brain and changing stuff but since I'm new there could be more errors in there I'm not seeing, here is the code in Python 3.6.2:</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>