top of page

Python: Sets

A set is a collection that is both unordered and unindexed.
Sets are written with curly brackets.

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.

thisset = {"cherry", "strawberry", "blueberry"}
print(thisset)

Set Items
Set items are unordered, unchangeable, and do not allow duplicate values.

Unordered
Unordered means that the items in a set do not have order.

Set items can appear in a different order every time, and cannot be referred to by index.

Unchangeable
Sets are unchangeable, meaning that we cannot change the items inside.

©2020 by Global Tech Nomads. 
Special thanks to X

bottom of page