From the course: Programming Concepts for Python
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Create and combine sets - Python Tutorial
From the course: Programming Concepts for Python
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,…