课程: Programming Concepts for Python
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
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,…