beginnerconceptual7 min
Explain mutable versus immutable values in Python.
Explain mutable versus immutable values in Python with examples.
Expected Answer
Mutable values can change in place, such as lists and dictionaries. Immutable values, such as strings, integers, and tuples, create new values when changed.
Detailed Explanation
Interviewers are checking whether you understand side effects and shared references, especially with lists and dictionaries.
Common Follow-up Questions
- Why can mutation cause bugs?
- Are tuples always deeply immutable?