IndexError in this code
<p>When I use this as the contents of the input file:</p>

<pre><code>1,3,5,7,9,11
</code></pre>

<p>I receive this error: </p>

<pre><code>IndexError: li
</code></pre>

<hr>

<pre><code>with open('fig.fig') as o:
    n = 6
    for i in range(1, 2*n, 2):
        print(o.readlines()[i].replace(' ', ''))
</code></pre>

<p>there is nothing wrong with the following code:</p>

<pre><code>n = 6  
for i in range(1, 2*n, 2):  
    print &lt;something&gt;[i].replace(' ', '')
</code></pre>

<p>so the problem is in the open or reading of your file (really open? line length?). Hope that helps.</p>

python indexing file-access