I have a list contains different names:
list = ['Tom', 'Mary', 'Robin', 'Tom']
What I want to do, is to replace 'Tom'
with 'MESSAGE'
and everyone else as 'RESPONSE'
.
Like below:
list = ['MESSAGE', 'RESPONSE', 'RESPONSE', 'MESSAGE']
Is there a way to do it? Preferably using only one line of code.