Appending lists according to a per of lists (IndexError: list index out of range) : I have these lists:

    n_crit = [[1, 2, 3, 4, 5, 6], [1, 1, 1, 1, 1, 1], [-1, 1, -1, -1, -1, 1], [2, 3, 5, 4, 1, 6], [10, 0, 0.5, 1, 0, 0], [0, 30, 5, 6, 0, 0], [0, 0, 0, 0, 0, 5]]

    crit = [[80, 90, 6, 5.4, 8, 5], [65, 58, 2, 9.7, 1, 1], [83, 60, 4, 7.2, 4, 7], [40, 80, 10, 7.5, 7, 10], [52, 72, 6, 2, 3, 8], [94, 96, 7, 3.6, 5, 6]]

and i have these code:

    DivMatrix = []
    for x in range(len(crit)):
        subList1 = []
        for y in range(len(crit[x])):
            subList2 = []
            if (n_crit[2][x]>0):
                for z in range(len(crit[x])):
                    subList2.append(crit[y][x] - crit[z][x])
            elif (n_crit[2][x]<0):
                for z in range(len(crit[x])):
                    subList2.append(-(crit[y][x] - crit[z][x]))   
            subList1.append(subList2)
        DivMatrix.append(subList1)    
    
Now i want to use the same code for another per of lists that are:

    n_crit = [[1, 2, 3, 4, 5], [0.23, 0.15, 0.15, 0.215, 0.255], [-1, -1, 1, 1, 1], [2, 6, 5, 4, 1], [4000, 0, 20, 0, 0], [0, 0, 40, 2, 0], [0, 1.5, 0, 0, 0]]

    crit = [[15000, 7, 60, 3, 3], [27000, 9, 120, 7, 7], [19000, 8.5, 90, 4, 5], [36000, 10, 140, 8, 7]]

But instead i get this error message:

    subList2.append(-(crit[y][x] - crit[z][x]))
    IndexError: list index out of range
I really dont know what is wrong but i want to use this code for any per of lists i want.


