Search code examples
pythonvariables

What's the difference between [ ] and { } when defining a variable (Python)?


I saw others use

CurlyBraces = {'Lorem','Ipsum'}

for their tables in python, but some others use

SquareBrackets = ['Lorem','Ipsum']

for their tables, what's the difference?


Solution

  • Curly Braces creates a Set (https://www.w3schools.com/python/python_sets.asp) or Dictionary, while square braces creates List (https://www.w3schools.com/python/python_lists.asp).

    A set is an unordered data structure, best for finding items fast, while a list is an ordered data structure