I am trying to make a code that changes a letter to another according to a dictionary. If it finds the letter "o" in a string, it changes to "e", for example. The way I came up with technically worked but still adds more elements for some reason and I couldn't figure it out unfortunately. (Python beginner) Here is the code:
dict1 = {"o":"e", "p":"l"}
text = "op"
text2 = ""
for key,value in dict1.items():
y = text.replace(key,value)
text2 +=y
print(text2)