title: Python can't access second element in list IndexError: list index out of range
body: <p>I have a text file formatted like this:</p>
  
  <pre><code>Jeff:2
  Bob:7
  Adam:4
  </code></pre>
  
  <p>I've read the data from the text file and created a list for each line. So that it looks like this when I run the program.</p>
  
  <pre><code>['']
  ['Jeff', '2']
  ['Bob', '7']
  ['Adam', '4']
  </code></pre>
  
  <p>However I want to assign a variable to the first and second elements in the lists so that I can sort the integers from highest to lowest but it keep getting an error, which I can't solve. </p>
  
  <p>Here is my code: </p>
  
  <pre><code>if choice == 1:
      f = open("group1.txt", 'r')
      for line in f:
          line = line.strip("\n").lstrip().rstrip().split(":")
          print(line)
          name = line[0]
          scores = int(line[1])
  
          print(scores)
  </code></pre>
  
  <p>It gives the error</p>
  
  <pre><code>scores = line[1]
  IndexError: list index out of range
  </code></pre>
  
  <p>I'm not sure why it doesn't work the number is the second element within the list "line"</p>
  
  <p>How can I fix this? Thanks for any help in advance</p>