Mutable & Immutable Data types

Immutable data types in Python are objects whose values cannot be changed after they are created.

Common examples include integers, floats, strings, tuples, booleans, and frozensets. Understanding immutability helps you write safer, more predictable code and makes it easier to work with features like dictionary keys and sets.

If you ever need to "modify" an immutable object, remember that you’re actually creating a new object with the desired value!

Immutable

int, str, float, tuple, bool

Mutable

list, dict, set

Updated on