Replace String with another in Python
In order to do it, we will use Replace() method in Python:
replace() function:
In this example, we replace the string “World” with “LearnDuty” in the text variable a.
a = "Hello, World!"
print(a.replace("World", "LearnDuty"))
Output:
Hello, LearnDuty!