50. Problem to find intersection of sets

In this Python set program, we will find the intersection of sets i.e. common books between two sets with the help of the below-given steps.

What is set?
Sets are used to store multiple items in a single variable.
The set is one of 4 built-in data types in Python used to store collections of data.
It is an unordered collection data type that is iterable, mutable and has no duplicate elements.

Intersection of sets:

Steps to solve the program

1. Create two sets having books name in it.
2. Use a for loop to iterate over books in the first set.
3. Use an if statement to check whether the book is present in the second set i.e. intersection of sets.
4. If yes then print that book.

Output :

Related Articles

create a set of your favorite movies.

find the longest word in a set.

Leave a Comment