w3resource logo

:

Python Exercises

Python Exercise: Intersection of sets

Python sets: Exercise-6 with Solution

Write a Python program to create an intersection of sets.

Sample Solution:-

Python Code:


#Intersection
setx = set(["green", "blue"])
sety = set(["blue", "yellow"])
setz = setx & sety
print(setz)

Sample Output:

{'blue'}

Python Code Editor:

Improve this sample solution and post your code through Disqus