Link Search Menu Expand Document

⚖ Comparison Table for Python Data Structures

Data StructureMake WithOrdered?Mutable?Can have duplicates?Examples
String'' or "" or str()YesNoYes"CSW8", str(3.75)
List[ ] or list()YesYesYes[12, 9.8], list("ABCDEF")
Tuple( ) or tuple()YesNoYes('Tu', 'Th'), tuple(['Tu', 'Th'])
Dictionary{ } or dict()NoYeskeys: No, values: Yes{1: "Mon", 2: "Tue"}, dict(Mon = 1, Tue = 2)
Set{ } or set()NoYesNo{"Jan", "Feb", "Feb"}, set("ABCDEF")

The constructor functions are usually used to create an empty object or a new object of that type with the input values of a different type converted into its elements.


Acknowledgements

Specials thanks to Allison Horst for creating the initial table.