Python program to replace the string space with a given character?

empty_string = " "
fruit=“Apple”
empty_string = empty_string .replace(" ",fruit)
print(empty_string)

4 Likes

Good one @brindhubala30

1 Like

@parkar-ta-ds parka thank you sir…

1 Like

@brindhubala30

Correct keep it up.

1 Like

phrase = “Edoyda”
substituted_phrase = phrase.replace(“o”, “a” )
print(phrase)
print(substituted_phrase)

output
Edoyda
Edayda

Done by Amarjeet Kumar

@amarjeetkumar1605

Correct, keep it up.

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)

@nyalakondasriharsha1

Correct, keep it up.