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

Clarify set order in intersection

At the end of the video, it is said that with union and symmetric difference, the order of sets doesn't matter, but with the rest it does.

I understand why in the difference method, but not in the intersection method. Why does order matter in intersection?

Tyvm!

1 Answer

Hi Narcis,

I don't think order would matter on intersection.

Union, Intersection and the Symmetric Difference operations are commutative and the order would not matter.

For the difference operation the order would matter. set1 - set2 is not the same as set2 - set1

Hi Jason!

That's what I thought... i just wanted to be sure =)