Create dict from two lists
Paul McGuire
ptmcg at austin.rr._bogus_.com
Fri Feb 10 08:55:37 EST 2006
"py" <codecraig at gmail.com> wrote in message
news:1139579518.129742.265680 at o13g2000cwo.googlegroups.com...
> 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.
>
> thanks.
>
>>> x = [1,2,3,4,5]
>>> y = ['a','b','c','d','e']
>>> dict(zip(x,y))
{1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e'}
-- Paul
More information about the Python-list
mailing list