Interview Q&A / Python

BeginnerIn-depth3 min readUpdated 2 Oct 2026

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

SHORT ANSWER

A list is mutable, so you can add, remove or change items after creating it. A tuple is immutable, so its contents are fixed once created. Tuples are slightly lighter and can be used as dictionary keys if all their items are hashable; lists cannot.

Explain it simply

Think of a list as a shopping list written in pencil. You can add items, scratch some out and change the order. A tuple is like the date of birth printed on your Aadhaar card. Once it is printed, nobody edits it; if something is wrong, a new card is issued.

Both hold an ordered sequence of items, both support indexing like x[0] and slicing like x[1:3], and both can hold mixed types. The main difference is whether the container can change after you create it.

Example

python
marks = [72, 85, 90]        # list: square brackets
marks.append(66)            # allowed
marks[0] = 75               # allowed
print(marks)                # [75, 85, 90, 66]

point = (12.97, 77.59)      # tuple: round brackets (Bengaluru lat, long)
print(point[0])             # 12.97
point[0] = 13.0             # TypeError: 'tuple' object does not support item assignment

# Tuples can be dictionary keys, lists cannot
distance = {(12.97, 77.59): "Bengaluru"}   # works
# distance = {[12.97, 77.59]: "Bengaluru"} # TypeError: unhashable type: 'list'

How it works

  • A list stores references to its items in a resizable array. Python keeps some spare room at the end, so append is fast on average.
  • A tuple is allocated once with exactly the size it needs. Because it can never grow, it has less overhead and is a little faster to create.
  • A tuple is hashable when every item inside it is hashable, which is why it can be a dictionary key or go into a set.
  • Lists have many methods (append, extend, insert, remove, pop, sort). Tuples have only count and index.

Real-world use

  • Lists for collections that change: the items in a Swiggy cart, rows read from a CSV, results you build up in a loop.
  • Tuples for fixed records: a coordinate pair, an RGB colour, a (name, roll number) pair, or returning several values from a function with return total, average.
  • Tuples as keys: caching results by (source, destination) station pair in a train search.

Common mistakes

  • Writing (5) and expecting a tuple. That is just the number 5. A one-item tuple needs a comma: (5,).
  • Believing a tuple is fully frozen. If a tuple holds a list, that inner list can still change: t = ([1, 2], 3) then t[0].append(4) works. Such a tuple is also not hashable.
  • Using a tuple for data you keep editing, then converting back and forth with list() and tuple().

What to say in the interview

"Both are ordered sequences, but a list is mutable and a tuple is immutable. I use a list when the data will change, like items in a cart, and a tuple for fixed records like coordinates or for returning multiple values from a function. Because tuples cannot change, they are a bit lighter, and if all their items are hashable they can be used as dictionary keys or set members, which lists cannot. One catch is that immutability is shallow: a tuple holding a list cannot swap that list out, but the list itself can still be modified."

Follow-up questions

  • Why can a tuple be a dictionary key but a list cannot?
  • How do you make a tuple with a single element?
  • What is a namedtuple and when would you use it?
  • Is t = (1, 2); t += (3,) changing the tuple?

Go deeper

Read these once the basics above feel easy.

t += (3,) does not modify the tuple. It builds a new tuple (1, 2, 3) and rebinds the name t to it. You can confirm this with id(t) before and after: the id changes. With a list, += calls extend and changes the same object in place, so the id stays the same.

collections.namedtuple and typing.NamedTuple give tuples readable field names, like student.roll_no instead of student[1], while keeping them immutable and lightweight.

#python#lists#tuples#data-types

Related questions

Practise more Python questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Python quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.