How to use string.replace() in python 3.x

StackOverflow

The string.replace() is deprecated on python 3.x. What is the new way of doing this?

Answer rating: 361

As in 2.x, use str.replace().

Example:

>>> "Hello world".replace("world", "Guido")
"Hello Guido"




Get Solution for free from DataCamp guru