thanks to everyone's help i got to this step but I have a few new problems that I hope someone can help me with,I found the following you words and want to replace them with another word but this code only works for the first word
import Re
text = 'Suddenly you said goodbye, even though I was passionately in love with you, I hope you stay lonely and live for a hundred years'
def replace(text,key,value,NumberL):
matches = list(re.finditer(key,text,re.I))
for i in NumberL:
newT = matches[i-1]
text = text[:newT.start(0)] + value + text[newT.end(0):]
print(text)
replace(text,'you','Cleis',[2,3])
result: Suddenly you said goodbye, even though I was passionately in love with Cleis, I ''hopCleisou'' stay lonely and live for a hundred years.
I edited and highlighted the error word.
Can someone give me a solution to this problem?