I have a sample file that looks like this:
@XXXXXXXXX
VXVXVXVXVX
+
ZZZZZZZZZZZ
@AAAAAA
YBYBYBYBYBYBYB
ZZZZZZZZZZZZ
...
I wish to only read the lines that fall on the index 4i+2, where i starts at 0. So I should read the VXVXV (4*0+2 = 2)...
line and the YBYB...(4*1 +2 = 6)
line in the snippet above. I need to count the number of 'V's, 'X's,'Y's and 'B's
and store in a pre-existing dict.
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
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?