Skip to content
Advertisement

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

I want to combine these:

JavaScript

Into a single dictionary:

JavaScript

Advertisement

Answer

Like this:

JavaScript

Voila :-) The pairwise dict constructor and zip function are awesomely useful.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement