Skip to content

List is mutable or immutable in Python

  • by

Lists are mutable data types in Python because the elements of the list can be modified, replaced, and the order of elements can be changed even after the list has been created.

An example list is mutable or immutable in Python

Simple example code once a list has been created can be modified, replaced or the order of elements can be changed

Python Lists are also dynamic.

lst = ['A', 'B', 'C', 'D']

lst[2] = "New"

print(lst)

Output: If the list is immutable then TypeError will throw by the compiler.

List is mutable or immutable in Python

Do comment if you have any doubts or suggestions on this Python List tutorial.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading