same elements of two sets in python 1

same elements of two sets in python

x = {2, 3, 5, 6}
y = {1, 2, 3, 4}

z = x.intersection(y)

Here is what the above code is Doing:
1. We create two sets, x and y.
2. We use the intersection method to find the common elements between x and y.
3. We store the result in a new set, z.

Similar Posts