title: Why is this index out of range?
body: <p>So I basically I want this to loop three times, as you can see I have choices = 0,1,2 and for <code>m</code> in range 3 so this should loop three times, first being for choice 0 then for choice 1 then for choice two. So why is this out of range? </p>
  
  <p>Pythons exact error return:</p>
  
  <pre><code>choices[r]=p.nextInt()
  IndexError: list assignment index out of range
  </code></pre>
  
  <p>please ignore <code>p.next</code> as this is how we must write it at uni as we have our own module.</p>
  
  <p>Here is my code </p>
  
  <pre><code>cities=["Coventry", "Birmingham", "Wolverhampton", "Leicester"]
  distances=[
      [0,25,33,24],
      [25,0,17,42],
      [33,17,0,54],
      [24,42,54,0]]
  
  def distancesthree():
      choices=[0,1,2] 
      for m in range(3): #This will loop three times!
          for r in range(len(cities)):
              p.write ("%d : %s\n" %(r, cities[r]))
          p.write("\nEnter city number %d: \n"%(m+1))
          choices[r]=p.nextInt()
  </code></pre>