What are Python’s mutable and immutable types?
What are Python’s mutable and immutable types?
Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
Anubhav Kumar
25-Aug-2025In Python, data types are break in tow part, either mutable or immutable based on whether their values can be changed after they are created.
Mutable Types:
Mutable objects can be modified after their creation without changing their memory address. This means that operations can be performed directly on the object (same address) to alter its content.
Examples of built-in mutable types:
list: Ordered, changeable collection of items.dict: Unordered, changeable collection of key-value pairs.set: Unordered, changeable collection of unique items.bytearray: Mutable sequence of bytes.Immutable Types:
Immutable objects cannot be changed after their creation. Any operation that appears to modify an immutable object actually results in the creation of a new object with the modified value. The original object remains unchanged.
Examples of built-in immutable types:
int: Integers.float: Floating-point numbers.str: Strings (sequences of characters).tuple: Ordered, unchangeable collection of items.frozenset: Immutable version of a set.bool: Boolean values (True/False).Read More