What is the difference between a list and a dictionary?
Why Interviewers Ask This
This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Python topics. It also reveals how well you can explain technical ideas to non-experts.
Answer
A list is an ordered sequence accessed by integer indices (0-based). It stores items without explicit keys: fruits = ["apple", "banana", "cherry"]; access by index: fruits[0]. A dictionary is an unordered (insertion-ordered in Python 3.7+) mapping that stores key-value pairs: user = {"name": "Alice", "age": 25}; access by key: user["name"]. Dictionaries provide O(1) average lookup time regardless of size (like a hash map). Lists provide O(1) access by index but O(n) search by value. Use lists when the order matters and data is accessed by position; use dictionaries when data has meaningful labels/keys and fast lookup by key is needed.
Common Mistake
Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real Python project.
Previous
What is the difference between a list and a tuple in Python?
Next
What is Python's indentation rule?