Answers for "intersection of two sets in python"

1

python check if two sets intersect

a = [1, 2, 3]
b = [3, 4, 5]

bool(set(a) & set(b))
Posted by: Guest on October-06-2020
1

intersection between two sets python

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

z = x.intersection(y)
    
print(z)

# Output: {"apple"}
Posted by: Guest on November-07-2020
1

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
Posted by: Guest on March-28-2021

Code answers related to "intersection of two sets in python"

Python Answers by Framework

Browse Popular Code Answers by Language