Set is a data type in python used to store several items in a single variable. It is one of the four built-in data types (List, Dictionary, Tuple, and Set) having qualities and usage different from the other three. It is a collection that is written with curly brackets and is both unindexed and unordered.
Items of a set in python are immutable (unchangeable), do not duplicate values, and unordered. Thus, items in a set do not appear in a stipulated manner, i.e., they can appear in a different order every time it is used. Due to this, set items cannot be referred to by key or index.
Set items can be of any data type: String, Boolean, tuple, float, int.
To create a python set, place all elements or items separated by a comma inside curly braces {}. The built-in set() function can also be used to create a set in python. Mutable elements such as dictionaries, lists, or sets are not allowed as its elements.
Collection
[
|
...
]