What is the difference between a list and a tuple in Python?
💡 Model Answer
A list is a mutable, ordered sequence that can be modified after creation; you can add, remove, or change elements. A tuple is immutable, meaning once it is created its contents cannot be altered. Because tuples are immutable, they can be used as keys in dictionaries or stored in sets, whereas lists cannot. Lists are implemented as dynamic arrays, offering O(1) access and amortized O(1) append, while tuples are stored more compactly and can be slightly faster for iteration. Use a list when you need a collection that changes; use a tuple when you want a fixed, hashable sequence or to signal that the data should remain constant.
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