python if any in list in other list code example
Example 1: check if a list contains an item from another list python
## checking any elment of list_B in list_A
list_A = [1, 2, 3, 4]
list_B = [2, 3, 6]
check = any(item in list_A for item in list_B)
print(check)
# True
Example 2: python check list contains another list
>>> items = set([-1, 0, 1, 2])
>>> set([1, 2]).issubset(items)
True
>>> set([1, 3]).issubset(items)
False