if strings in python are immutable, then how are we able to perform the s.replace function
Doubt in a concept
Hey @vageesha,
Strings in Python are immutable and functions like replace, they just return the copy of the object after replacing the string. To check this you can check the id of str.replace method it will be a new id that means a new memory location. Link For Code
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.