What is the difference between a list, set, and dictionary?
💡 Model Answer
A list is an ordered, mutable collection that can contain duplicate elements. It preserves insertion order and allows indexing and slicing. A set is an unordered collection of unique elements; it is mutable but does not maintain order and automatically removes duplicates. A dictionary (or map) stores key-value pairs; keys are unique and hashable, values can be any type. Dictionaries are unordered prior to Python 3.7, but from 3.7 onward they preserve insertion order. All three are mutable, but lists support indexing, sets support membership tests, and dictionaries support key-based lookup. Example: list = [1, 2, 3]; set = {1, 2, 3}; dict = {"a": 1, "b": 2}.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500