How to check if an element from List A is not present in List B in Python?

If I have one element alone this is easy:

>>> 3 not in [2, 3, 4]
False
>>> 3 not in [4, 5, 6]
True

But what if I have two lists and have to check if the elements in list A occur in list B?

A=[1,2,3,4]
B=[4,5,6,7]

How do I get a results showing me that 1,2,3 are not in list B?

Best answer

Using list comprehension:

truthy answer

any([True for x in [1, 2, 3, 4] if x in [4, 5, 6, 7]])

list of elements not present in the second list

[x for x in [1, 2, 3, 4] if x not in [4, 5, 6, 7]]