Building lists

MRAB python at mrabarnett.plus.com
Mon Oct 20 18:57:54 EDT 2014


On 2014-10-20 23:30, Denis McMahon wrote:
> On Mon, 20 Oct 2014 20:40:18 +0100, MRAB wrote:
>
>> There are a number of stores, so that would be a list of stores. For
>> each store you want the price of each item, so that would be a dict
>> where the key is the item and the value is the price of that item. That
>> means it would be a list of dicts.
>>
>> Does that help?
>
> It think it would be a dict of dicts:
>
> shopping = { "store1" : { "item1": price1, "item2": price2, ...  },
> "store2" : { "item3": price3, "item4": price4, ... }, ... }
>
The OP never said that the stores have names! :-)



More information about the Python-list mailing list