I have two lists A1 and J1 containing many sublists. From each sublist of A1[0], I want to remove the element specified in J1[0]. I present the current and expected outputs.
A1 = [[[1, 3, 4, 6], [0, 2, 3, 5]], [[1, 3, 4, 6], [1, 3, 4, 6]]] J1 = [[[1], [2]], [[1], [4]]] arD = [] for i in range(0,len(A1)): for j in range(0,len(J1)): C=set(A1[i][j])-set(J1[i][j]) D=list(C) arD.append(D) D=list(arD) print("D =",D) The current output is
D = [[3, 4, 6], [0, 3, 5], [3, 4, 6], [1, 3, 6]] The expected output is
D = [[[3, 4, 6], [0, 3, 5]],[[3, 4, 6],[1, 3, 6]]]