- Are immutable, but unlike tuples, they only permit characters as its contents. Specified with
""
.
a = "Hello World"
print(a[1])
print(a[4:9])
Important: since they can’t change, all the methods applied to immutable objects are making copies of them! For example:
a = "Hello"
b = a.upper()
print(b)
print(id(a))
print(id(b))
HELLO
140402468101104
140402467911024