I want to write a code to create a dictionary from a table that maps fruits to dictionaries of their quantity in different baskets.
table = [['Fruit', 'Basket1', 'Basket2', 'Basket3'],
['Apples', 4, 5, 6],
['Bananas', 7, 8, 10],
['Oranges', 8, 9, 2]]
Expected dictionary: {'Apples': {'Basket1':[4],'Basket2':[5],'Basket3':[6]}, 'Bananas':{'Basket1':[7],'Basket2':[8],'Basket3':[10]}, 'Oranges':{'Basket1':[8],'Basket2':[9],'Basket3':[2]}}
Expected Output: [Apples][Basket1]= 4
Below is what I have so far. I know the last 2 lines don't make sense, but I have a hard time figuring out how to close this one out.
basket = [y for y in table[0] if y!='Fruit']
Quantity=[y[1:4] for y in table if y[0]!='Fruit']
Fruit = [y[0] for y in table if y[0]!='Fruit']
a = dict(zip(Fruit, Quantity))
b = dict(zip(a,Basket)
b
Expected Output: [Apples][Basket1]= 4while dictionary is of lists.