empty_string = " "
fruit=“Apple”
empty_string = empty_string .replace(" ",fruit)
print(empty_string)
4 Likes
phrase = “Edoyda”
substituted_phrase = phrase.replace(“o”, “a” )
print(phrase)
print(substituted_phrase)
output
Edoyda
Edayda
Done by Amarjeet Kumar
print("Enter the String: ")
str = input()
print("Enter the old character to search for: ")
oldchar = input()
print("Enter the new character to replace with: ")
newchar = input()
str = str.replace(oldchar, newchar)
print("\nThe new string is: ")
print(str)