[Tutor] create dict from 2 lists

BRINER Cedric work at infomaniak.ch
Fri Apr 2 08:19:42 EST 2004


hi,

assume that I want to create the dict:
p={1:11,2:22,3:33,4:44}

and that i have:
the keys=[1,2,3,4]       and
the values=[11,22,33,44]

Is the simpliest way to do this, is to do :
p={}
for i in range(len(keys)):
   p[keys[i]]=values[i]

or is there a hidded function which do this?

Cédric BRINER




More information about the Tutor mailing list