1
2# Python3 program to demonstrate the
3# use of replace() method
4
5string = "geeks for geeks geeks geeks geeks"
6
7# Prints the string by replacing geeks by Geeks
8print(string.replace("geeks", "Geeks"))
9
10# Prints the string by replacing only 3 occurrence of Geeks
11print(string.replace("geeks", "GeeksforGeeks", 3))
1#our text
2text='Hello there how may I help you!'
3 #replacing ("THIS" with "THIS")
4replaced_text=text.replace("!", "?")
5print(replaced_text)
6#output
7"Hello there how may I help you?"