Intersecting two sets

In the following diagram, we can see that, where both sets intersect, we should get a list of any movies they have in common:

We can do the same using the intersection() method in our code. Let's intersect both movie lists and see what happens:

craigsFavMovieSet.intersection(gabesFavMovieSet) 

Your code and output should now look like this:

We can see that the only two movies that these sets have in common are The Illusionist and Winter Solider. In addition to seeing which movies the two sets have in common, we can also join the lists to get one consolidated list of the movies from both sets.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.96.146