Last Updated: February 25, 2016
·
323
· _kokopak_

Make a dictionnary with two lists

We've two lists :

l1 = ["name", "age", "sex"]
l2 = ["John" , 23, "man"]

Next, if we want a dictionnary with the keys in the first list and the values in the second we can do :

d = dict(zip(l1, l2))
print d
# >>> {'age': 23, 'name': 'John', 'sex': 'man'}

Very useful for CSV parsing