Immutable
adjective
say it: “ih-MYOO-tuh-bul” /ɪˈmjuːtəbəl/
Describes a value that can't be changed after it's made; you make a new value instead. Strings, numbers and tuples are immutable.
What does immutable mean?
An immutable value can't be changed after it's created; you make a new one instead. Strings, numbers and tuples are immutable.
name = "sam"
name.upper() # makes a NEW string
print(name) # sam (unchanged)
name = name.upper() # keep the new one
print(name) # SAM
In a sentence
- “A tuple is immutable: you can't change its first item.”
- “Strings are immutable, so name.upper() makes a new string.”
Level: Apprentice · More Python terms at this level
Updated