How can I make a dictionary from separate lists of keys and values?

Like this:

keys = ['a', 'b', 'c']
values = [1, 2, 3]
dictionary = dict(zip(keys, values))
print(dictionary) # {'a': 1, 'b': 2, 'c': 3}

Voila 🙂 The pairwise dict constructor and zip function are awesomely useful.

Leave a Comment