In python strings are immutable meaning they can’t be changed and when we apply a method we are getting a new string…
explain to me how does this work then?
str1 = "fdjsklafdsa"
str1 = str1.replace("fdjsklafdsa", "This")
print(str1)
result -> This
is this creating a new string of str1
? What happens to the previous one?? I’m confused pls help
New contributor
Anubhav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1