I'm trying to find a reliable way to check if a positional list element in a list2
(all same length) does not exist in any i for i in list1
?
This looks like the opposite of what I need:
How to check if one of the following items is in a list?
>>> list1 = [('1', '2', '3'), ('a', 'b', 'c'), ('4', '5', '6')]
>>> list2 = [('a', 'b', 'c'), ('m', 'n', 'b'), ('p', 'q', '6')]
>>> print(any(z in [i[2] for i in list1] for z in [z for x,y,z in list2]))
True
Ideally I want ('m','n,'b')
of list2
because 'b'
is not found in any 3rd element of list1
, so how do I segregate it out?
Instead of 'any' I am looking for this sort of pseudo code:
print x,y,z from list2 if 'z' is not found in any 3rd position element in all the lists present in "list1"