I want to detect which item in a list that is replaced while ignoring occurance in the list, suppose I have:
before_list = ['C1', 'C16', 'C23', 'C14', 'C23', 'C13', 'C11', 'C19', 'C27', 'C10', 'C16', 'C28', 'C11', 'C8', 'C2', 'C27', 'C18', 'C27']
after_list = ['C1', 'C16', 'C23', 'C23', 'C13', 'C11', 'C19', 'C10', 'C16', 'C28', 'C8', 'C18', 'C27', 'C1', 'C14', 'C22', 'C16', 'C6']
I want to detect which item has been replaced by comparing before_list
and after_list
, and produce a list of the replaced item
to_be_replaced = ['C27','C11','C2','C27']
replace_with = ['C1','C22','C16','C6']
Can anyone help me with how to do this?