Open this example in the interactive library
Source code
from collections import Counter
wanted = Counter(['A', 'A', 'B', 'C'])
stock = Counter(['A', 'B', 'B'])
print(list((wanted & stock).elements()))
Sample output
['A', 'B']

Compute a multiset overlap of requested parts using Python lists and dictionaries.
Open this example in the interactive library
from collections import Counter
wanted = Counter(['A', 'A', 'B', 'C'])
stock = Counter(['A', 'B', 'B'])
print(list((wanted & stock).elements()))
['A', 'B']