I have a list like this:
list1 = ['hello', 'halo', 'goodbye', 'bye bye', 'how are you?']
I want for example to replace ‘hello’ and ‘halo’ with ‘welcome’, and ‘goodbye’ and ‘bye bye’ with ‘greetings’ so the list will be like this:
list1 or newlist = ['welcome', 'welcome', 'greetings', 'greetings', 'how are you?']
how can I do that the shortest way?
I tried this, but it didn’t work unless I convert my list to string first but I want it to be list, any way I converted to string and changed the words and then I tried to convert it back to list but wasn’t converted back properly.