What is the difference between mutable and immutable types in Python?
Ask by ICSM Computer
Updated 27 Mar 2025
Mutable vs Immutable Types in Python
In Python, mutability refers to whether an object can be changed after it is created. Based on this, Python data types are classified as:
Mutable Types (Can Change)
These objects allow modifications without changing their identity (memory location).
Examples of Mutable Types
listdict(dictionary)setbytearrayExample of a Mutable List
Immutable Types (Cannot Change)
Once an object is created, it cannot be modified. Any modification creates a new object in memory.
Examples of Immutable Types
intfloatbooltuplestrfrozensetbytesExample of an Immutable String
Key Differences Between Mutable and Immutable Types
list,dict,setint,float,str,tuple