Square brackets are lists while parentheses are tuples.

A list is mutable, meaning you can change its contents:

>>> x = [1,2]
>>> x.append(3)
>>> x
[1, 2, 3]

while tuples are not:

>>> x = (1,2)
>>> x
(1, 2)
>>> x.append(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'append'

The other main difference is that a tuple is hashable, meaning that you can use it as a key to a dictionary, among other things. For example:

>>> x = (1,2)
>>> y = [1,2]
>>> z = {}
>>> z[x] = 3
>>> z
{(1, 2): 3}
>>> z[y] = 4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'

Note that, as many people have pointed out, you can add tuples together. For example:

>>> x = (1,2)
>>> x += (3,)
>>> x
(1, 2, 3)

However, this does not mean tuples are mutable. In the example above, a new tuple is constructed by adding together the two tuples as arguments. The original tuple is not modified. To demonstrate this, consider the following:

>>> x = (1,2)
>>> y = x
>>> x += (3,)
>>> x
(1, 2, 3)
>>> y
(1, 2)

Whereas, if you were to construct this same example with a list, y would also be updated:

>>> x = [1, 2]
>>> y = x
>>> x += [3]
>>> x
[1, 2, 3]
>>> y
[1, 2, 3]
Answer from jterrace on Stack Overflow
Top answer
1 of 7
332

Square brackets are lists while parentheses are tuples.

A list is mutable, meaning you can change its contents:

>>> x = [1,2]
>>> x.append(3)
>>> x
[1, 2, 3]

while tuples are not:

>>> x = (1,2)
>>> x
(1, 2)
>>> x.append(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'append'

The other main difference is that a tuple is hashable, meaning that you can use it as a key to a dictionary, among other things. For example:

>>> x = (1,2)
>>> y = [1,2]
>>> z = {}
>>> z[x] = 3
>>> z
{(1, 2): 3}
>>> z[y] = 4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'

Note that, as many people have pointed out, you can add tuples together. For example:

>>> x = (1,2)
>>> x += (3,)
>>> x
(1, 2, 3)

However, this does not mean tuples are mutable. In the example above, a new tuple is constructed by adding together the two tuples as arguments. The original tuple is not modified. To demonstrate this, consider the following:

>>> x = (1,2)
>>> y = x
>>> x += (3,)
>>> x
(1, 2, 3)
>>> y
(1, 2)

Whereas, if you were to construct this same example with a list, y would also be updated:

>>> x = [1, 2]
>>> y = x
>>> x += [3]
>>> x
[1, 2, 3]
>>> y
[1, 2, 3]
2 of 7
14

One interesting difference :

lst=[1]
print lst          // prints [1]
print type(lst)    // prints <type 'list'>

notATuple=(1)
print notATuple        // prints 1
print type(notATuple)  // prints <type 'int'>
                                         ^^ instead of tuple(expected)

A comma must be included in a tuple even if it contains only a single value. e.g. (1,) instead of (1).

🌐
Data Science Discovery
discovery.cs.illinois.edu › guides › Python-Fundamentals › brackets
Parentheses, Square Brackets and Curly Braces in Python - Data Science Discovery
March 22, 2024 - Brief description on when to use parentheses `()`, square brackets `[]` and curly braces `{}` in python
Discussions

Meaning of square brackets
Ok, I think I have got it now. it is about the indexing of a list. I think it is referring to the last two elements of the list called mails · The first thing to understand is that the output from split() is a list. See the documentation for str.split(). A list is a sequence type · The second ... More on discuss.python.org
🌐 discuss.python.org
0
0
October 24, 2022
Question regarding using square brackets to access values of variables
You are accessing a reference at some index. Or, in the case of dictionaries, some key. This holds true regardless of how you're actually making use of it. However, as a general case it could technically do nearly anything, as it's simply calling the object's __getitem__-method under the hood. The above example print("I am learning about " + python_topics[index]) could therefore be technically written as print("I am learning about " + python_topics.__getitem__(index)) although, of course, no sane person would outside of an example case like this one. More on reddit.com
🌐 r/learnpython
15
1
February 4, 2025
In python, when to use a square or round brackets? - Stack Overflow
They are part of the Python syntax and unlike using single (') or double (") quotes, they can pretty much never be interchanged. Square and rounded brackets can mean so many different things in different circumstances. Just to give an example, one may think that both the following are identical: ... as a[0] gives 1 in both cases. However, the first one is creating a list ... More on stackoverflow.com
🌐 stackoverflow.com
Why Square Brackets in Dictionaries
Why do I need to use square brackets when accessing the value from a dictionary like in the code below: · The square brackets and also the use of .get(...) are the syntax of Python that has been chosen by the language designers · Because that’s the Python syntax for referencing a key or ... More on discuss.python.org
🌐 discuss.python.org
0
0
June 11, 2025
🌐
Codecademy
codecademy.com › learn › cspath-cs-101 › modules › cspath-python-lists › cheatsheet
CS101: Introduction to Programming: Python: Lists Cheatsheet | Codecademy
In Python, lists are ordered collections of items that allow for easy use of a set of data. List values are placed in between square brackets [ ], separated by commas. It is good practice to put a space between the comma and the next value.
🌐
Python.org
discuss.python.org › python help
Meaning of square brackets - Python Help - Discussions on Python.org
October 24, 2022 - Ok, I think I have got it now. it is about the indexing of a list. I think it is referring to the last two elements of the list called mails · The first thing to understand is that the output from split() is a list. See the documentation for str.split(). A list is a sequence type · The second ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › parentheses-square-brackets-and-curly-braces-in-python
Parentheses, Square Brackets and Curly Braces in Python - GeeksforGeeks
July 26, 2025 - Curly braces define dictionaries and sets, both of which are mutable collections. Square brackets are crucial for defining lists and accessing elements through indexing and slicing. Mastery of these symbols allows Python developers to effectively manipulate data structures and perform various operations, enhancing their coding proficiency.
🌐
Oreate AI
oreateai.com › blog › understanding-the-role-of-square-brackets-in-python › 11e53ced7a30c49381742208fbb219e6
Understanding the Role of Square Brackets in Python - Oreate AI Blog
January 16, 2026 - For instance, you can create a list by simply enclosing elements within square brackets: my_list = [1, 2, 3]. This creates a collection that can hold various types of items—numbers, strings, or even other lists.
🌐
DataCamp
campus.datacamp.com › courses › intermediate-python › dictionaries-pandas
Square Brackets (1) - Intermediate Python
The single bracket version gives a Pandas Series, the double bracket version gives a Pandas DataFrame. ... Use single square brackets to print out the country column of cars as a Pandas Series.
🌐
SheCodes
shecodes.io › athena › 2453-how-to-use-square-bracket-syntax-in-python
[Python] - How to Use Square Bracket Syntax in Python - | SheCodes
Learn what square bracket syntax is and how to use it to access elements of an array or dictionary in Python.
Find elsewhere
🌐
YouTube
youtube.com › watch
How to Use Square Brackets in Python - YouTube
Using Python parentheses correctly is important to avoid syntax errors. We continue our three-part Python Parentheses series with square brackets. Square bra...
Published   March 7, 2023
🌐
Reddit
reddit.com › r/learnpython › question regarding using square brackets to access values of variables
r/learnpython on Reddit: Question regarding using square brackets to access values of variables
February 4, 2025 -

Hello,

Please review the code in bold.

My question is in both examples,

Example 1.

python_topics = ["variables", "control flow", "loops", "modules", "classes"]

length = len(python_topics)

index = 0

while index < length:

print("I am learning about " + python_topics[index])

index += 1

Example 2.

favorite_fruit = "blueberry"

last_char = favorite_fruit**[len(favorite_fruit) - 1]**

Output: Y

My question is, their a way to describe what the square brackets are doing? Would you say that the square brackets are used to access or transfer the value of the variable? Hopefully this question makes sense. Thank you very much.

🌐
Runestone Academy
runestone.academy › ns › books › published › fopp › Sequences › IndexOperatorWorkingwiththeCharactersofaString.html
6.3. Index Operator: Working with the Characters of a String — Foundations of Python Programming
The indexing operator (Python uses square brackets to enclose the index) selects a single character from a string. The characters are accessed by their position or index value.
🌐
Quora
quora.com › What-is-the-use-of-square-brackets-in-Python-except-list
What is the use of square brackets in Python, except list? - Quora
Answer (1 of 4): [] apart from being used to represent an empty list can also be used in the following ways: array indexing: [code]a = [1, 2, 3, 4, 5] # access first element print(a[0]) # access last element print(a[-1]) [/code]dictionary indexing: ...
🌐
Open Book Project
openbookproject.net › books › bpp4awd › ch03.html
3. Strings, lists and tuples — Beginning Python Programming for Aspiring Web Developers
In the case of lists or tuples, they are made up of elements, which are values of any Python datatype, including other lists and tuples. Lists are enclosed in square brackets ([ and ]) and tuples in parentheses (( and )).
🌐
Medium
medium.com › @mydotanis_1814 › understanding-square-brackets-in-python-ee8b5288fc15
Understanding Square Brackets [ ] in Python | by MYAns | Medium
March 3, 2025 - 4. List Comprehension: The [ ] sign is used in a comprehension list to create a new list in a concise way. Example: squares = [x**2 for x in range(5)] # Output: [0, 1, 4, 9, 16]
Top answer
1 of 3
14

They are part of the Python syntax and unlike using single (') or double (") quotes, they can pretty much never be interchanged.

Square and rounded brackets can mean so many different things in different circumstances. Just to give an example, one may think that both the following are identical:

a = [1,2,3]
a = (1,2,3)

as a[0] gives 1 in both cases. However, the first one is creating a list whereas the second is a tuple. These are different data types and not knowing the distinction can lead to difficulties.

Above is just one example where square and rounded brackets differ but there are many, many others. For example, in an expression such as:

4 * ((12 + 6) / 9)

using square brackets would lead to a syntax error as Python would think you were trying to create a nested list:

4 * [[12 + 6] / 9]

So hopefully you can see from above, that the two types of brackets do completely different things in situations which seem identical. There is no real rule of thumb for when one type does what. In general, I guess that square brackets are used mainly for lists and indexing things whereas rounded brackets are for calculations (as you would in maths) and functions etc.

Hope this helps you out a bit!

2 of 3
7

It's hard to answer succinctly, but I can give you some common examples.

Square brackets define lists:

my_list = [1, 2, 3, 4]

They are also used for indexing lists. For instance:

print(my_list[1])

Returns 2. Additionally, they are frequently used to index dictionaries, which are defined with curly brackets:

my_dict = {5:'a', 6:'b', 7:'c'}

The indexing for dictionaries requires that I input the "key" as follows:

print(my_dict[6])

Returns b.

Functions are called using round brackets. For instance, if I want to add an element to my list, I can call the append() function:

my_list.append(8)

I have just added 8 to my list. You will notice that when I called the print function I also used curved brackets.

This is by no means comprehensive, but hopefully it will give a starting point.

🌐
Python.org
discuss.python.org › python help
Why Square Brackets in Dictionaries - Python Help - Discussions on Python.org
June 11, 2025 - Why do I need to use square brackets when accessing the value from a dictionary like in the code below: · The square brackets and also the use of .get(...) are the syntax of Python that has been chosen by the language designers · Because that’s the Python syntax for referencing a key or ...
🌐
GeeksforGeeks
geeksforgeeks.org › python-remove-square-brackets-from-list
Python | Remove square brackets from list | GeeksforGeeks
April 13, 2023 - Print the final concatenated string using print("List after removing square brackets : " + res). Below is the implementation of the above approach: ... # Python3 code to demonstrate working of # Remove square brackets from list # using a loop to concatenate elements to a string # initialize list test_list = [5, 6, 8, 9, 10, 21] # printing original list print("The original list is : " + str(test_list)) # Remove square brackets from list # using a loop to concatenate elements to a string res = "" for i in range(len(test_list)): if i == 0: res += str(test_list[i]) else: res += ", " + str(test_list[i]) # printing result print("List after removing square brackets : " + res)
🌐
Google
developers.google.com › google for education › python › python lists
Python Lists | Python Education | Google for Developers
January 23, 2026 - Python has a great built-in list type named "list". List literals are written within square brackets [ ]. Lists work similarly to strings -- use the len() function and square brackets [ ] to access data, with the first element at index 0.
🌐
Processing
py.processing.org › reference › indexbrackets
[] (Index brackets) \ Language (API)
Python Mode for Processing extends the Processing Development Environment with the Python programming language.
🌐
Codecademy
codecademy.com › learn › ida-2-introduction-to-python › modules › ida-2-3-python-lists › cheatsheet
Introduction to Python: Lists in Python Cheatsheet | Codecademy
In Python, lists are ordered collections of items that allow for easy use of a set of data. List values are placed in between square brackets [ ], separated by commas. It is good practice to put a space between the comma and the next value.