Create dict from two lists

Diez B. Roggisch deets at nospam.web.de
Fri Feb 10 08:54:44 EST 2006


py wrote:

> I have two lists which I want to use to create a dictionary.  List x
> would be the keys, and list y is the values.
> 
> x = [1,2,3,4,5]
> y = ['a','b','c','d','e']
> 
> Any suggestions?  looking for an efficent simple way to do this...maybe
> i am just having a brain fart...i feel like this is quit simple.

dict(zip(x,y))

Diez



More information about the Python-list mailing list