about dictionary

bonono at gmail.com bonono at gmail.com
Sun Nov 20 05:59:30 EST 2005


b = dict([(x,dict()) for x in a])
Shi Mu wrote:
> I have have the following code:
> >>> a=[3,5,8,0]
> >>> b={}
> >>>
> How I can i assign each item in a as the key in the dictionary b
> simultaneously?
> that is,
> b={3:[],5:[],8:[],0:[]}
> Thanks!




More information about the Python-list mailing list