I have state_array function. If if state ist true, i'm deleting item from list result. It's not working because for-loop ist out of range.
I wat to fix it, and want to ask, it is possible to have list comprehension instead of 'for-loop', if yes, how to do that ?
def state_array(self):
    for k in range(len(result)):
        if '[0]' in str(result[k]):
            if '[7]' in str(result[k+7]) and '[8]' not in str(result[k+8]):
                result[k][0] = str(result[k][0]).replace('[0]', '').replace('X0', 'X0,8')                      # state array
                del result[k+1:k+7]
            else:
                continue
My input:
V;3;M_BB01_03[0];SPPP.BK1800.58,X0;RW
V;3;M_BB01_03[1];SPPP.BK1800.58,X1;RW
V;3;M_BB01_03[2];SPPP.BK1800.58,X2;RW
V;3;M_BB01_03[3];SPPP.BK1800.58,X3;RW
V;3;M_BB01_03[4];SPPP.BK1800.58,X4;RW
V;3;M_BB01_03[5];SPPP.BK1800.58,X5;RW
V;3;M_BB01_03[6];SPPP.BK1800.58,X6;RW
V;3;M_BB01_03[7];SPPP.BK1800.58,X7;RW
And expected output:
V;3;M_BB01_03[0];SPPP.BK1800.58,X0,8;RW
 
     
    