I have a list:
my_colors = ['blue', 'blue', 'blue', 'red', 'red', 'green']
And I have a 'valid' list:
valid_colors = ['red', 'white', 'blue']
How can I remove any items in my list that are not in the valid list (valid_colors
)? So that I get: my_colors = ['blue', 'blue', 'blue', 'red', 'red']
(no green)