replace() string method in Python
The replace() is an built-in string method replaces all occurrences of a substring with another.
Syntax string.replace(old, new, count)
Example:
Python
text = "I like Java. Java is popular."
print(text.replace("Java", "Python"))
# Output: I like Python. Python is popular. Special Note: • The count parameter limits replacements.
• Returns a new string.