title: Python list index out of range on return value of split
body: <p>I'm writing a simple script that is trying to extract the first element from the second column of a .txt input file. </p>
  
  <pre><code>import sys
  
  if (len(sys.argv) &gt; 1):
      f = open(sys.argv[1], "r");
      print "file opened";
  
  line = [];
  
  for line in f:
      line = line.strip("\n ' '")
      line = line.split(",") 
      print line[1]
  
  f.close();
  </code></pre>
  
  <p>My input file looks like this:</p>
  
  <pre><code>Client 192.168.1.13 said ``ACC: d0bb38f18da536aff7b455264eba2f1e35dd976f,389182.567,-0.042,-0.893,0.333''
  Client 192.168.1.13 said ``ACC: d0bb38f18da536aff7b455264eba2f1e35dd976f,389182.590,-0.036,-0.905,0.273''
  Client 192.168.1.13 said ``ACC: d0bb38f18da536aff7b455264eba2f1e35dd976f,389182.611,-0.046,-0.948,0.204''
  Client 192.168.1.13 said ``ACC: d0bb38f18da536aff7b455264eba2f1e35dd976f,389182.631,-0.074,-0.978,0.170''
  Client 192.168.1.13 said ``ACC: d0bb38f18da536aff7b455264eba2f1e35dd976f,389182.654,-0.100,-1.006,0.171''
  </code></pre>
  
  <p>I want my delimiter to be a comma. When I print the length of the line out, I'm getting 5 elements (as expected). However, whenever I try to index the list to extract the data (i.e., when I call <code>print line[1]</code>), I keep getting the following error:</p>
  
  <pre><code>file opened
  Traceback (most recent call last):
    File "stats.py", line 13, in &lt;module&gt;
      print line[1]
  IndexError: list index out of range
  </code></pre>
  
  <p>I don't understand why it's out of range when clearly it isn't.</p>