python check if two sets intersect
a = [1, 2, 3]
b = [3, 4, 5]
bool(set(a) & set(b))
python check if two sets intersect
a = [1, 2, 3]
b = [3, 4, 5]
bool(set(a) & set(b))
intersection between two sets python
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.intersection(y)
print(z)
# Output: {"apple"}
python set intersection
both = {'a', 'A', 'b', 'B'}
some = {'a', 'b', 'c'}
result1 = both & some
# result: {'a', 'b'}
result2 = both.intersection(some)
print(result1 == result2)
# True
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us