🐍 Python Beginner

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

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Python basics — a prerequisite for any developer role.

Answer

Both lists and tuples are ordered sequences that can hold items of any type. The key difference is mutability. A list ([1, 2, 3]) is mutable — you can add, remove, and change elements after creation. A tuple ((1, 2, 3)) is immutable — once created, it cannot be changed. Tuples are slightly faster than lists, use less memory, and can be used as dictionary keys (since they are hashable). Use tuples for fixed collections of heterogeneous data (like a record or coordinates) and lists for homogeneous sequences that may change. Named tuples (collections.namedtuple) add field names to tuples without the overhead of a full class.

Pro Tip

Back up your answer with a specific project or situation. Saying 'In my last Python project, I used this when...' immediately makes your answer more credible and memorable.