0
Why string isn't changed ?
soz = "Python" soz.replace("P" , "7" ) print(soz)
4 Respostas
+ 3
You need to understand that string are NOT mutable : contrary to lists, for instance, you cannot change its content.
All methods that "change" a string actually return a new string with changes applied (the old one isn't modified). So when working with strings, always store the result!
+ 6
You need to store or use the return value of replace-method. It does not apply it's return value automatically on the object it was executed with.
+ 1
Théophile , Perfect Answer to the question.