From the course: Programming Foundations: Real-World Examples

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create and combine sets

Create and combine sets - Python Tutorial

From the course: Programming Foundations: Real-World Examples

Start my 1-month free trial

Create and combine sets

- If you have a collection of different objects that you want to store together, and the order of those objects doesn't matter, then they can be organized into a set. A set is a data structure to store an unordered collection of unique objects, meaning that no two objects in the set are identical. I think I'll invite some friends over tonight for an epic evening of board games. Now to figure out who to invite. As a modern man, I keep track of all my friends through social networks, but I keep them organized into different groups. I have one group for my college buddies, another group for my coworkers, and also a group for my family friends. Each of these three groups of friends represents a set, which is an unordered collection of unique items, in this case, my friends. Representing them in a set is different from a list because there is no ranking or order to the set. I can't tell you who my number one friend is because they are all equally good friends within each set. These three…

Contents