I'm having trouble searching if a key and corresponding value from one dictionary (stock) is in another dictionary (basket)
this is the error I receive:
File "C:/Users/mbbx2wc3/.spyder2-py3/temp.py", line 35, in <module>
if stock['10005'] in basket:
TypeError: unhashable type: 'dict'
And this is my code if you want to have a look. I have tried is stock[key] in basket. but this gives an error and I cannot think of an alternative to try.
Many thanks
stock = {
'10005' : {
'name' : 'Conference Pears Loose',
'price' : 2.00,
'unit' : 'kg',
'promotion' : None,
'group' : None,
'amount' : 1.550
},
'10013' : {
'name' : 'Emmental Slices 250G',
'price' : 1.75,
'unit' : 'pieces',
'promotion' : 'get2pay1',
'group' : None,
'amount' : 9
},
'10015' : {
'name' : 'Diced Beef 400G',
'price' : 4.50,
'unit' : 'pieces',
'promotion': 'get4pay3',
'group' : 4,
'amount' : 14
}}
basket = {}
if stock['10005'] in basket:
print("yay")
else:
print("noo")