I am looking to remove the contents of one array from another.
array_2 = ['one' , "two" , "one", "three", "four"] array_1 = ['one', "two"]
My first thought was to use list comprehensions
array_3 = [x for x in array_2 if x not in array_1]
However this will remove the duplicate item
I want to only remove
"one" once from the array as I am looking for a list subtraction. So I want the result to be :
['one', 'three', 'four'].
What is a good pythonic way to achieve this ?