Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (2016, retired 2019) Sets Set Math

Mark Rae
Mark Rae
4,503 Points

Are there instances where order matters with Intersection?

The video mentions that order of set1 and set2 does not matter for Union and Symmetric Difference. It seems like the same would be true of Intersection, and that's what I've seen when I played with the operation.

Are there situations where set1 & set2 would NOT equal set2 & set1?

2 Answers

Mark Rae
Mark Rae
4,503 Points

Decided to read about sets on Wikipedia. Turns out that "Intersection is also commutative; for any A and B, one has A ∩ B = B ∩ A."

Iulia Maria Lungu
Iulia Maria Lungu
16,923 Points

I'm glad someone else had this question as well :)