877 B
Executable File
877 B
Executable File
python-set
Sets are used to store multiple items in a single variable.
Set is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Tuple, and Dictionary, all with different qualities and usage.
A set is a collection which is unordered, unchangeable*, and unindexed.
*Note: Set items are unchangeable, but you can remove items and add new items.
Sets are written with curly brackets. Example:
# Create a Set:
thisset = {"apple", "banana", "cherry"}
print(thisset)
Notes:
Sets are fast, Note that empty Set cannot be created through {}, it creates a dictionary, unless you include values. set is implemented as a hash table, so you can expect lookup, insert, delete to be O(1) on average.