I have a list which looks like this:
working_list=['one', 'two', 'three', 'four', 'five']
And I want to have a new list which would look like this:
output_list=['one or two','one or two','three','four or five','four or five']
For that, I have created two other lists:
old_names=[['one','two'],['four','five']]
new_names=['one or two','four or five']
And then I tried:
output_list=[]
for item in working_list:
for a_list in old_names:
if item in a_list:
index=old_names.index(a_list)
new_name=new_names[index]
output_list.append(new_name)
else:
output_list.append(item)
print(output_list)
But that gives me an output:
['one or two', 'one', 'one or two', 'two', 'three', 'three', 'four', 'four or five', 'five', 'four or five']
Any ideas on how to solve this?
Would greatly appreciate it!