check intersection of two sets python code example
Example 1: python check if two sets intersect
a = [1, 2, 3]
b = [3, 4, 5]
bool(set(a) & set(b))
Example 2: intersection between two sets python
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.intersection(y)
print(z)
# Output: {"apple"}