Dictionary from a list

Diez B. Roggisch deets at nospam.web.de
Wed Aug 19 22:39:47 CEST 2009


iu2 schrieb:
> Hi all,
> 
> I need to create a dictionary out of a list.
> 
> Given the list [1, 2, 3, 4, 5, 6]
> 
> I need the dictionary: {1:2, 3:4, 5:6}

dict(zip(l[::2], l[1::2]))

Diez



More information about the Python-list mailing list