title: Why would I get IndexError: list index out of range. When the list index could not be out of range?
body: <p>I've been building a dice game, and when I got to the part where I assign images to each Tkinter label so that the dice display, I started getting this error:</p>
  
  <pre><code>Exception in Tkinter callback
  Traceback (most recent call last):
    File "C:\Python27\lib\lib-tk\Tkinter.py", line 1486, in __call__
      return self.func(*args)
    File "C:/Users/Logan/Desktop/Dice/dicelab2.py", line 56, in rollDice
      self.dice[i].roll()
    File "C:/Users/Logan/Desktop/Dice/dicelab2.py", line 35, in roll
      self.display.config(image=Photolist[self.value-1])
  IndexError: list index out of range
  </code></pre>
  
  <p>Now the list has 6 entries in it, and I am calling it from self. value. Self.value is supposed to be a random integer between 1 and 6. Before I call it I subtract 1 so that it should be within the index of Photolist. What else could be causing this error?
  Here's my code:</p>
  
  <pre><code>import Tkinter
  import random
  Photolist=[]
  
  class Die:
  
      def __init__(self,frame):        
          self.value = random.randint(1,6)
          print self.value
          photo1=Tkinter.PhotoImage(file="1.gif")
          photo2=Tkinter.PhotoImage(file="2.gif")
          photo3=Tkinter.PhotoImage(file="3.gif")
          photo4=Tkinter.PhotoImage(file="4.gif")
          photo5=Tkinter.PhotoImage(file="5.gif")
          photo6=Tkinter.PhotoImage(file="6.gif")
  
          Photolist=[photo1,photo2,photo3,photo4,photo5,photo6]
  
          self.display = Tkinter.Label(frame,
            image=Photolist[self.value-1],
            font=('Courier New',30),
            relief='ridge',
            borderwidth=5,
            bg='white')
          self.display.pack(side='left')
  
      def roll(self):
          self.value = random.randint(1,6)
          print self.value
          self.display.config(image=Photolist[self.value-1])
  
  class DiceRoller:
      def __init__(self):
          gameWin = Tkinter.Tk()
          gameWin.title('Dice Roller')
          diceFrame = Tkinter.Frame(gameWin)
          self.dice = [ ]
          for i in range(5):
              self.dice.append(Die(diceFrame))
  
          rollBtn = Tkinter.Button(gameWin,
            text='Roll Again',
            command=self.rollDice,
            font=('Courier New',30)) 
          diceFrame.pack()
          rollBtn.pack(side='bottom')
          gameWin.mainloop()
  
      def rollDice(self):
          for i in range(5):
              self.dice[i].roll()
  
  
  dice = DiceRoller()
  dice
  </code></pre>