Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Python Sets!
You have completed Python Sets!
There are four main set operations that allow you to compare and contrast collections like a Venn Diagram. Union and Intersection are two methods for comparing shared membership between sets.
Main Set Operations
The following methods and operations return a new set.
s.intersection(t)
/ s & t
- Return the intersection of two sets as a new set. (i.e. all elements that are in both sets.)
s.union(t)
/ s | t
- Return the union of sets as a new set. (i.e. all elements that are in either set.)
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up