printing out elements in list

I V wrongbad at gmail.com
Mon May 8 04:05:29 EDT 2006


On Mon, 08 May 2006 00:44:39 -0700, micklee74 wrote:
> i have a list with contents like this
> alist = ['>QWER' , 'askfhs', '>REWR' ,'sfsdf' , '>FGDG',
> 'sdfsdgffdgfdg' ]
> 
> how can i "convert" this list into a dictionary such that
> 
> dictionary = { '>QWER':'askfhs' , '>REWR' : 'sfsdf' , '>FGDG',
> 'sdfsdgffdgfdg' }

This strikes me as a little bit voodish, but you could do:

dictionary = dict(zip(alist[::2], alist[1::2]))



More information about the Python-list mailing list