namelist = ['John', 'Maria']
e_text = 'John is hunting, Maria is cooking'
I need to replace 'John' and 'Maria'. How can I do this?
I tried:
for name in namelist:
if name in e_text:
e_text.replace(name, 'replaced')
But it only works with 'John'. The output is: 'replaced is hunting, Maria is cooking'. How can I replace the two names?
Thanks.