replace a word in a string in python
Code snippet on how to replace a word in a string in python
newString = oldString.replace("old word","new word")
This code replaces an old word with a new word in an old string. The first step is to create a variable to store the new string. The old string is provided as input and the old word and new word are also provided as input. The replace() method is then applied to the oldString variable and the old word is replaced by the new word. The new string is then stored in the newString variable.