Replace All Occurrences of a Substring in a String using Python

replace method

text = 'abc def ghi abc'
result = text.replace('abc', '123')

print(result)  # 123 def ghi 123

Leave a Comment

Cancel reply

Your email address will not be published.