![]() |
VOOZH | about |
Yes, tuples are immutable in Python. This means that once a tuple is created its elements cannot be changed, added or removed. The immutability of tuples makes them a fixed, unchangeable collection of items. This property distinguishes tuples from lists, which are mutable and allow for modifications after creation.
Let’s see an example where we attempt to modify a tuple:
Error: 'tuple' object does not support item assignment
As you can see, attempting to modify an element in a tuple results in a TypeError, which confirms that tuples are immutable.