I would like to subtract a list of strings where there are more than one element of the same (so set operations are not useful).
Example:
C = ['A','B','B']
D = ['B']
I would like a way to do so that:
C - D = ['A','B']
Example of what I got so far, but does not give the result I want
[item for item in C if item not in D]
returns: ['A']
Here is a more elaborated example to show what I want:
C = ['A','B', 'A','A','B','B','B','X','B']
D = ['A','B','B','Y']
This is what I want the result to be:
C - D = ['A', 'A', 'B', 'B','B','X']