1## checking any elment of list_B in list_A
2list_A = [1, 2, 3, 4]
3
4list_B = [2, 3, 6]
5
6check = any(item in list_A for item in list_B)
7
8print(check)
9# True
1## checking all elements of list_B in list_A
2list_A = [1, 2, 3, 4]
3list_B = [2, 3]
4
5check = all(item in list_A for item in list_B)
6
7print(check)
8# True
1## using set
2list_A = [1, 2, 3, 4]
3list_B = [2, 3]
4
5set_A = set(list_A)
6set_B = set(list_B)
7
8print(set_A.intersection(set_B))
9
10# True if there is any element same
11# False if there is no element same
1## using set
2list_A = [1, 2, 3, 4]
3list_B = [5,1]
4
5set_A = set(list_A)
6set_B = set(list_B)
7
8output = False if (set_A.intersection(set_B) == set()) else True
9print(output)
10# True if there is any element same
11# False if there is no element same