Python

Python Immutable Objects

For mutable objects, such as a list, to operate on a list, the contents within the list will change, for example. >>> l = [‘f’, ‘e’, ‘d’] >>> l.sort() >>> ; [‘d’, ‘e’, ‘f’] What about immutable objects, like string. >>> str = ‘hello’ >>> str.replace(‘h’, ‘F’) ‘Fello’ >>> str ‘hello’ Even though the string

Python Immutable Objects Read More »