How to find if one or multiple specific sub-strings of an element of a list is duplicate. As in present in the other elements of the list, and then make the list unique by only keeping the first element that has those sub-strings in them and remove every other one (the elements that contain the duplicates).
Example:
SUBSTRINGS=['banana','chocolate']
MYLIST=['1 banana cake','2 banana cake','3 cherry cake','4 chocolate cake','5 chocolate cake','6 banana cake','7 pineapple cake']
The repeating substrings are banana
and chocolate
in this case.After the processing the list should become:
MYLIST=['1 banana cake','3 cherry cake','4 chocolate cake','7 pineapple cake']