Read specific sequence of lines in Python
<p>I have a sample file that looks like this:</p>

<pre><code>    @XXXXXXXXX
    VXVXVXVXVX
    +
    ZZZZZZZZZZZ
    @AAAAAA
    YBYBYBYBYBYBYB
    ZZZZZZZZZZZZ
    ...
</code></pre>

<p>I wish to only read the lines that fall on the index 4i+2, where i starts at 0. So I should read the <code>VXVXV (4*0+2 = 2)...</code> line and the <code>YBYB...(4*1 +2 = 6)</code>line in the snippet above. I need to count the number of <code>'V's, 'X's,'Y's and 'B's</code> and store in a pre-existing dict. </p>

<pre><code>fp = open(fileName, "r")
lines = fp.readlines()

for i in xrange(1, len(lines),4):
    for c in str(lines(i)):
        if c == 'V':
             some_dict['V'] +=1
</code></pre>

<p>Can someone explain how do I avoid going off index and only read in the lines at the 4*i+2 index of the lines list?</p>