Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,935 Points

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