While union()
gives us all elements of the two sets, interection()
gives us only the common ones.
We can save the sets given by intersection()
in a variable like common
.
>>> data1 = {1,2,3}
>>> data2 = {3,4,5}
>>> common = data1.intersection(data2)
>>> common
{3}