set.intersection() in python



"intersection()" function is used to find the element which is common in the given two set. It will store the common elements by creating a new set.




Syntax:




set.intersection(set_value)







Example-1
n = {10, 30, 50}

m = {10, 70, 100}

a = n.intersection(m)

print(a)


Output



{10}







Example-2
n = {20, 30, 50}

m = {10, 70, 100}

a = n.intersection(m)

print(a)


Output



set()







Example-3
n = {"A", "B", "C"}

m = {"A", "D", "E"}

a = n.intersection(m)

print(a)


Output



{'A'}