title: Python list index error (student files)
body: <p>I am having problem with a list for an averaging program, it says:</p>
  
  <p>'line 20, in 
      nameletter = (letter[int(num)])
  IndexError: list index out of range'</p>
  
  <p>This is the part of the code: </p>
  
  <pre><code>    f2 = open("Classes" + "/Sorted/" + "Alphabetical.txt", "w")
  
  letter = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
  
  print(letter[num])
  
  #Loop
  while num &lt;= 26:
      nameletter = (letter[int(num)])
      if os.path.exists("Classes" + "/" + nameletter + ".txt"):
          #Opening the students file
          f = open("Classes" + "/" + nameletter + ".txt")
          List = f.read().splitlines()
          f.close()
          #Writing data to the file
          f2.write(List[5] + " - score = " + List[6])
          f2.write("\n")
      else:
          pass
      num = int(num) + 1
  f2.close()
  </code></pre>