Open this example in the interactive library
Source code
parts = [('A', 'pen', 4), ('B', 'pen', 7)]
stock = {(zone, sku): qty for zone, sku, qty in parts}
print(stock['B', 'pen'])
Sample output
7

Index products by a composite tuple using Python lists and dictionaries.
Open this example in the interactive library
parts = [('A', 'pen', 4), ('B', 'pen', 7)]
stock = {(zone, sku): qty for zone, sku, qty in parts}
print(stock['B', 'pen'])
7