Everything in python is considered an object. There are two types of objects in python, mutable and immutable types.
mutable object state can be changed.
immutable object state cannot be changed.
Mutable types are list, dictionary, set
Immutable types are int, float, complex, bool, str, tuple, frozen_set
### output
['apples', 'grapes', 'mangoes', 'bananas']
### OUTPUT
Traceback (most recent call last):
File "E:\Python-Samples\BASICS\sample.py", line 7, in <module>
fruits[0] = 'bananas'
~~~~~~^^^
TypeError: 'tuple' object does not support item assignment
Some examples on mutable types:
Some examples of immutable types:
There is no update or append method in immutable types:
Comments