HOME/Articles/

python code immutable data type (snippet)

Article Outline

Python example 'python code immutable data type'

python code immutable data type

Python code example: python code immutable data type

>>> a = [1, 2, 4, 8, 16] >>> a[0] = 32 # OK. You can modify lists.
>>> a
[32, 2, 4, 8, 16]
>>> a = (1, 2, 4, 8, 16)
>>> a[0] = 32 # Wrong! You can't modify tuples.
Traceback (most recent call last):
File "", line 1, in
TypeError: 'tuple' object does not support item assignment

More Python: https://pythonprogramminglanguage.com