In our last article we left off discussing Python's version of arrays (the list and dictionary). I also gave you a brief introduction to some Operators. In this tutorial I will tell you about Python's remaining data holder, Sets, and prepare you for a later discussion of Operators in Python.
Although I said Lists do not have indexes in the previous article, it isn't quite true, as I demonstrated. Sets, which are used to hold a bunch of unordered values, truly have no index. And unlike Tuples and Lists, Sets can contain no duplicate data. To assign value to a set, simple do this:
mcdonaldgang = Set (['Grimace', 'Hamburglar', 'Mayor Mccheese'])
gangpassword = Set ("rubble")
The above code creates a set and assigns values to it (Grimace, Hamburglar, and Mayor McCheese). We then create a second set with the gang's password in it (rubble). Finally, we print out the values of each. Note that there is no index in Sets, so there is no particular order that the values would print: