What is the difference between a list and a tuple in Python?

The main difference is that a list is mutable (you can change it) and a tuple is immutable (you cannot change it after creating it).

PointListTuple
Brackets[ ]( )
Can change itemsYesNo
Speed and memoryA little slower, uses more memoryA little faster, uses less memory
MethodsMany, like append() and remove()Only count() and index()
Use as dictionary keyNoYes, if it holds only immutable items
my_list = [1, 2, 3]
my_list[0] = 10
print(my_list)

my_tuple = (1, 2, 3)
my_tuple[0] = 10

Output:

Tutorials Class - Output Window

[10, 2, 3]
TypeError: 'tuple' object does not support item assignment

Use a list when the data will change, and a tuple when it should stay fixed. Read more about lists and tuples.


Learn more about the similar topics:
Tutorials
Python Lists
Python Tuples
Python Sets
Python Dictionary
Exercises & Assignments
Python program to find largest and smallest number in a list
Python program to remove duplicates from a list
Interview Questions & Answers
What is a list in Python?
What is a tuple in Python?
What is a set in Python?
What is a dictionary in Python?
What is a negative index in Python and why is it used?
What is the difference between a list and a tuple in Python?
What are mutable and immutable types in Python?