Dictionary from a list

iu2 israelu at elbit.co.il
Wed Aug 19 16:52:54 EDT 2009


On Aug 19, 11:39 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> 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

Wow, this is cool!

thanks
iu2



More information about the Python-list mailing list