A variable holds a reference to an object. You can see the reference with id(varaible). The string object that you have a reference to is immutable. When you reassign the variable to a new string, the reference is updated to point to a new string object, and the old string object is unchanged. Edit: Note that assignment assigns a reference. No matter whether the object being referred to is mutable, assignment to a variable updates the variable's reference. Mutating an object means changing the data held within an object in place - i.e. its reference does not change when mutated. Answer from Goobyalus on reddit.com
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ what does 'strings are immutable' mean?
r/learnprogramming on Reddit: What does 'Strings are immutable' mean?
September 29, 2022 -

I'm using Treehouse for Python basics and the tutor mentions this in the context of reassigning a value to a string variable. But if the value of the string variable can be reassigned, what does it mean to say it's immutable? Is there something I'm just not getting? Thanks.

๐ŸŒ
Austin Z. Henley
austinhenley.com โ€บ blog โ€บ pythonstringsaremutable.html
Python strings are immutable, but only sometimes - Austin Z. Henley
February 15, 2021 - The standard wisdom is that Python strings are immutable. You can't change a string's value, only the reference to the string.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ why-are-python-strings-immutable
Why are Python Strings Immutable? - GeeksforGeeks
October 13, 2025 - Strings in Python are "immutable" i.e. they cannot be changed after they are created. Strings are immutable by design to keep them safe, consistent, and efficient.
๐ŸŒ
Medium
medium.com โ€บ @sking5006j โ€บ why-strings-are-immutable-in-python-91eb3a6dcecc
Why Strings Are Immutable in Python | by MOHAMMAD SUFIYAN SHAJAHAN SHAIKH | Medium
October 29, 2025 - In Python, everything is an object โ€” integers, lists, and strings. Each object has a type, identity, and value. When we say strings are immutable, it means their value cannot be altered after creation.
Find elsewhere
๐ŸŒ
Runestone Academy
runestone.academy โ€บ ns โ€บ books โ€บ published โ€บ FOPP-PIE โ€บ sequences_immutable-strings.html
9.3 Immutable Strings
What does that mean? When something is mutable it can change. When something is immutable, it cannot change. So, when we create a string, some memory is allocated to store that string. When we want to change that string, we have to actually create a new string.
๐ŸŒ
Medium
medium.com โ€บ @mvenkatashivaditya โ€บ why-are-strings-immutable-in-python-bfdbf1c1199a
Why Python Strings Are Immutable โ€” and Why It Matters | by Shivaditya Meduri | Medium
May 13, 2025 - TL;DR โ€” Python strings are immutable so that their hash value can be cached and to enable safe, efficient use as dict/set keys
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 1323097 โ€บ python-strings-are-immutable
Python strings are immutable? | Sololearn: Learn to code for FREE!
Strings are immutable in Python. t1="abcde" t2=t1.replace("b", "B") print(t1) #abcde print(t2) #aBcde As you can see, the replace method doesn't change the value of the string t1 itself. It just return a new string which can be used for other purposes.
๐ŸŒ
Kadenfrisk
python.kadenfrisk.com โ€บ strings in python โ€บ string immutability
Python String Immutability | Fluffy's Python Course
In Python, strings are immutable. This means that once a string object is created, its content cannot be changed.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ python_text_processing โ€บ python_string_immutability.htm
Python Text Processing - String Immutability
In python, the string data types are immutable. Which means a string value cannot be updated. We can verify this by trying to update a part of the string which will led us to an error.
๐ŸŒ
Hacker News
news.ycombinator.com โ€บ item
All strings in python are immutable, as an example. | Hacker News
July 25, 2025 - The standard library also has String, CString, CStr, OsString, and OsStr ยท The latter four are for niche situations. 99.9% of the time, it's similar to Java: &str is Java's String, String is Java's StringBuffer/StringBuilder
๐ŸŒ
EyeHunts
tutorial.eyehunts.com โ€บ home โ€บ strings are immutable in python | example code
Strings are immutable in Python | Example code
July 27, 2022 - Immutable objects are once created, will not change in their lifetime. Python strings are immutable. You can't change the value of the string
๐ŸŒ
Fatos Morina
fatosmorina.com โ€บ home โ€บ unveiling the immutable nature of strings in python
Unveiling the Immutable Nature of Strings in Python - Fatos Morina
July 2, 2023 - Strings are a fundamental data ... understand that strings in Python are immutable. This means that once a string is created, it cannot be modified in-place....
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ why-are-strings-in-python-immutable
Why are strings in Python immutable?
In Python, strings are made immutable so that programmers cannot alter the contents of the object (even by mistake).
๐ŸŒ
Medium
medium.com โ€บ nerd-for-tech โ€บ why-string-is-immutable-python-bfd934e09f19
The Unchanging Beauty: The Whys and Hows of Immutable Strings in Python | by Shilpa Sreekumar | Nerd For Tech | Medium
November 24, 2023 - The string data type is immutable in Python, meaning it is unable to be changed. As a result, the value of a string cannot be altered in Python.
๐ŸŒ
Hacker News
news.ycombinator.com โ€บ item
Python strings are immutable, but only sometimes | Hacker News
February 16, 2021 - This is an undocumented optimization, so you should assume you're allocating a new sting every single time like the internet says ยท I've been coding Python since 1.5.2 days and so I'll continue to use lists as intermediate string builders and then join afterwards because I know this works ...
๐ŸŒ
CodingNomads
codingnomads.com โ€บ python-string-immutability
Python Immutability
Python strings are immutable, which means that you can't change a string after you created it.