We can check if the object type is mutable or not by comparing the new memory location of modified variable with the originally defined variable.
For example - int() is an immutable object in Python. If I try to modify the value of integer type variable, I notice the memory location changes [Code and Output below]. Can someone provide a brief explanation going in the background ?
#initial variable
a = 10
# initial memory location
print(id(a))
#modified variable
a += 1
# new memory location, is it same?
print(id(a))
OUTPUT 93285870446416 93285870446524