So the Goal is: given a Nested list that contains 3 elements in each element in the nest, i.e. L1=[[1,2,3],[4,5,6],[7,8,9],[10,11,12]] how can I take a flat list, i.e. L2=[1,2,3,4,11] where if the elements within the nested list, i.e. L1[0], L1[1], etc. intersect with any single element in L2, the element within the nested list is returned into a different list, L3

OK, here's what I have:

L1=[[1,2,3],[4,5,6],[7,8,9],[10,11,12]]

L2=[1,2,3,4,11]

L3=[]

u=0

s=0

while s<=len(L2):

if L2[s] == L1[0][0]:

L1.pop(0)

if L2[s] == L1[0][1]:

L1.pop(0)

if L2[s] == L1[0][2]:

L1.pop(0)

else:

listy=L2[s+1]

while u<=JDAWGlen:

if listy == L1[0]:

L1.pop(u)

if listy == L1[1]:

L1.pop(u)

if listy == L1[2]:

L1.pop(u)

else: break

u+=1

s+=1

But this is where I freeze. How can I get the "popped" lists into a list L3? L3 should be L3=[[1,2,3],[4,5,6],[10,11,12]]

Maybe there is a much faster and better way to go about this- maybe by using a "for" loop. Or maybe there is a much much better way with a dictionary, but I have no idea how to use it for this. so step by step instructions would be helpful.