Like this:

Copykeys = ['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.

Answer from Dan Lenski on Stack Overflow
🌐
W3Schools
w3schools.com › python › python_dictionaries.asp
Python Dictionaries
Dictionaries are used to store data values in key:value pairs. A dictionary is a collection which is ordered*, changeable and do not allow duplicates. As of Python version 3.7, dictionaries are ordered. In Python 3.6 and earlier, dictionaries are unordered. Dictionaries are written with curly ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-dictionary
Python Dictionaries (with Examples) - GeeksforGeeks
Explanation: "name" and "age" are keys, "Jake" and 22 are their values and dictionary stores data in key:value format · A dictionary is created by writing key-value pairs inside { }, where each key is connected to a value using colon (:).
Published   1 week ago
🌐
GeeksforGeeks
geeksforgeeks.org › python › initialize-python-dictionary-with-keys-and-values
Initialize Python Dictionary with Keys and Values - GeeksforGeeks
July 23, 2025 - In this example, in below code Python dictionary named for_loop_person is created using a for loop to iterate over a list of keys, which includes "name" and "age." Within the loop, it checks each key, assigning values accordingly—setting "Bob" for the "name" key and 22 for the "age" key.
Top answer
1 of 16
3000

Like this:

Copykeys = ['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.

2 of 16
251

Imagine that you have:

Copykeys = ('name', 'age', 'food')
values = ('Monty', 42, 'spam')

What is the simplest way to produce the following dictionary ?

Copydict = {'name' : 'Monty', 'age' : 42, 'food' : 'spam'}

Most performant, dict constructor with zip

Copynew_dict = dict(zip(keys, values))

In Python 3, zip now returns a lazy iterator, and this is now the most performant approach.

dict(zip(keys, values)) does require the one-time global lookup each for dict and zip, but it doesn't form any unnecessary intermediate data-structures or have to deal with local lookups in function application.

Runner-up, dict comprehension:

A close runner-up to using the dict constructor is to use the native syntax of a dict comprehension (not a list comprehension, as others have mistakenly put it):

Copynew_dict = {k: v for k, v in zip(keys, values)}

Choose this when you need to map or filter based on the keys or value.

In Python 2, zip returns a list, to avoid creating an unnecessary list, use izip instead (aliased to zip can reduce code changes when you move to Python 3).

Copyfrom itertools import izip as zip

So that is still (2.7):

Copynew_dict = {k: v for k, v in zip(keys, values)}

Python 2, ideal for <= 2.6

izip from itertools becomes zip in Python 3. izip is better than zip for Python 2 (because it avoids the unnecessary list creation), and ideal for 2.6 or below:

Copyfrom itertools import izip
new_dict = dict(izip(keys, values))

Result for all cases:

In all cases:

Copy>>> new_dict
{'age': 42, 'name': 'Monty', 'food': 'spam'}

Explanation:

If we look at the help on dict we see that it takes a variety of forms of arguments:


>>> help(dict)

class dict(object)
 |  dict() -> new empty dictionary
 |  dict(mapping) -> new dictionary initialized from a mapping object's
 |      (key, value) pairs
 |  dict(iterable) -> new dictionary initialized as if via:
 |      d = {}
 |      for k, v in iterable:
 |          d[k] = v
 |  dict(**kwargs) -> new dictionary initialized with the name=value pairs
 |      in the keyword argument list.  For example:  dict(one=1, two=2)

The optimal approach is to use an iterable while avoiding creating unnecessary data structures. In Python 2, zip creates an unnecessary list:

Copy>>> zip(keys, values)
[('name', 'Monty'), ('age', 42), ('food', 'spam')]

In Python 3, the equivalent would be:

Copy>>> list(zip(keys, values))
[('name', 'Monty'), ('age', 42), ('food', 'spam')]

and Python 3's zip merely creates an iterable object:

Copy>>> zip(keys, values)
<zip object at 0x7f0e2ad029c8>

Since we want to avoid creating unnecessary data structures, we usually want to avoid Python 2's zip (since it creates an unnecessary list).

Less performant alternatives:

This is a generator expression being passed to the dict constructor:

Copygenerator_expression = ((k, v) for k, v in zip(keys, values))
dict(generator_expression)

or equivalently:

Copydict((k, v) for k, v in zip(keys, values))

And this is a list comprehension being passed to the dict constructor:

Copydict([(k, v) for k, v in zip(keys, values)])

In the first two cases, an extra layer of non-operative (thus unnecessary) computation is placed over the zip iterable, and in the case of the list comprehension, an extra list is unnecessarily created. I would expect all of them to be less performant, and certainly not more-so.

Performance review:

In 64 bit Python 3.8.2 provided by Nix, on Ubuntu 16.04, ordered from fastest to slowest:

Copy>>> min(timeit.repeat(lambda: dict(zip(keys, values))))
0.6695233230129816
>>> min(timeit.repeat(lambda: {k: v for k, v in zip(keys, values)}))
0.6941362579818815
>>> min(timeit.repeat(lambda: {keys[i]: values[i] for i in range(len(keys))}))
0.8782548159942962
>>> 
>>> min(timeit.repeat(lambda: dict([(k, v) for k, v in zip(keys, values)])))
1.077607496001292
>>> min(timeit.repeat(lambda: dict((k, v) for k, v in zip(keys, values))))
1.1840861019445583

dict(zip(keys, values)) wins even with small sets of keys and values, but for larger sets, the differences in performance will become greater.

A commenter said:

min seems like a bad way to compare performance. Surely mean and/or max would be much more useful indicators for real usage.

We use min because these algorithms are deterministic. We want to know the performance of the algorithms under the best conditions possible.

If the operating system hangs for any reason, it has nothing to do with what we're trying to compare, so we need to exclude those kinds of results from our analysis.

If we used mean, those kinds of events would skew our results greatly, and if we used max we will only get the most extreme result - the one most likely affected by such an event.

A commenter also says:

In python 3.6.8, using mean values, the dict comprehension is indeed still faster, by about 30% for these small lists. For larger lists (10k random numbers), the dict call is about 10% faster.

I presume we mean dict(zip(... with 10k random numbers. That does sound like a fairly unusual use case. It does makes sense that the most direct calls would dominate in large datasets, and I wouldn't be surprised if OS hangs are dominating given how long it would take to run that test, further skewing your numbers. And if you use mean or max I would consider your results meaningless.

Let's use a more realistic size on our top examples:

Copyimport numpy
import timeit
l1 = list(numpy.random.random(100))
l2 = list(numpy.random.random(100))

And we see here that dict(zip(... does indeed run faster for larger datasets by about 20%.

Copy>>> min(timeit.repeat(lambda: {k: v for k, v in zip(l1, l2)}))
9.698965263989521
>>> min(timeit.repeat(lambda: dict(zip(l1, l2))))
7.9965161079890095
🌐
TutorialsPoint
tutorialspoint.com › How-to-create-Python-dictionary-from-list-of-keys-and-values
How to create Python dictionary from list of keys and values?
April 17, 2025 - We can also create a dictionary from a single list. The index values are considered as keys, and the elements of the list are considered as the values of the dictionary. my_list=['a','b','c','d'] dic={} for i in range(len(my_list)): dic[i]=my_list[i] print(dic) ...
🌐
Real Python
realpython.com › python-dicts
Dictionaries in Python – Real Python
April 8, 2026 - The second way is to use the dict() constructor, which lets you create dictionaries from iterables of key-value pairs, other mappings, or a series of keyword arguments. It also lets you create empty dictionaries when you call it without arguments.
🌐
freeCodeCamp
freecodecamp.org › news › create-a-dictionary-in-python-python-dict-methods
Create a Dictionary in Python – Python Dict Methods
March 14, 2022 - A dictionary in Python is made up of key-value pairs. In the two sections that follow you will see two ways of creating a dictionary. The first way is by using a set of curly braces, {}, and the second way is by using the built-in dict() function.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Create a Dictionary in Python: {}, dict(), Dict Comprehensions | note.nkmk.me
August 21, 2023 - You can create a dictionary with dict(). Built-in Types - dict() — Python 3.11.3 documentation · There are several ways to specify arguments. You can use the keyword argument key=value.
Find elsewhere
🌐
Mimo
mimo.org › glossary › python › dictionary-dict-function
Python Dictionary: Syntax and Examples [Python Tutorial]
You can also create a dictionary using the dict() function and passing key-value pairs as keyword arguments. Using dict() without any arguments creates an empty dictionary.
🌐
StrataScratch
stratascratch.com › blog › python-dictionaries-master-key-value-data-structures
Python Dictionaries: Master Key-Value Data Structures - StrataScratch
July 20, 2023 - To create a dictionary comprehension, we start with an expression followed by a for loop inside curly braces {}. The expression consists of the key:value pairs separated by commas and is evaluated once for each item in the iterable object provided ...
🌐
PythonForBeginners
pythonforbeginners.com › home › python dictionary – how to create dictionaries in python
Python Dictionary - How To Create Dictionaries In Python - PythonForBeginners.com
June 30, 2023 - To create Python dictionaries with key-value pairs, you can use the curly braces approach as well as the dict() function. To create a dictionary with key-value pairs using the curly braces, you can enclose the key-value pairs inside the curly braces.
🌐
Programiz
programiz.com › python-programming › dictionary
Python Dictionary (With Examples)
March 26, 2024 - The country_capitals dictionary ... We cannot use mutable (changeable) objects such as lists as keys. We can also create a dictionary using a Python built-in function dict()....
🌐
Programiz
programiz.com › python-programming › methods › dictionary › fromkeys
Python Dictionary fromkeys() (With Examples)
Here, alphabets and numbers are the key and value of the dictionary. ... numbers (Optional) - are the values that can be of any type or any iterables like string, set, list, etc. Note: The same value is assigned to all the keys of the dictionary. ... Note: If the value of the dictionary is not provided, None is assigned to the keys. # set of vowels keys = {'a', 'e', 'i', 'o', 'u' } # assign string to the value value = 'vowel' # creates a dictionary with keys and values vowels = dict.fromkeys(keys, value) print(vowels)
🌐
Tutorialspoint
tutorialspoint.com › python › python_dictionary.htm
Python - Dictionaries
You can create a dictionary in Python by placing a comma-separated sequence of key-value pairs within curly braces {}, with a colon : separating each key and its associated value.
🌐
Stack Abuse
stackabuse.com › python-dictionary-tutorial
Guide to Dictionaries in Python
August 31, 2023 - That's also a pretty easy task in Python - say we have integer keys and string values: ... Dictionaries can also be nested, which means that we can create a dictionary inside another dictionary:
🌐
Medium
sokacoding.medium.com › 6-ways-to-initialize-a-dictionary-in-python-e9a0b1a5572e
6 Ways to initialize a Dictionary in Python | by sokacoding | Medium
January 24, 2023 - Instead of using curly braces, you write all your arguments inside the dict() constructor, replace the colons with equal signs and write your keys without quotation marks. ... However, this approach has one disadvantage compared to the first one.
🌐
Google
developers.google.com › google for education › python › python dict and file
Python Dict and File | Python Education | Google for Developers
## Note that the keys are in a random order. for key in dict: print(key) ## prints a g o ## Exactly the same as above for key in dict.keys(): print(key) ## Get the .keys() list: print(dict.keys()) ## dict_keys(['a', 'o', 'g']) ## Likewise, there's a .values() list of values print(dict.values()) ## dict_values(['alpha', 'omega', 'gamma']) ## Common case -- loop over the keys in sorted order, ## accessing each key/value for key in sorted(dict.keys()): print(key, dict[key]) ## .items() is the dict expressed as (key, value) tuples print(dict.items()) ## dict_items([('a', 'alpha'), ('o', 'omega'),
🌐
Python Like You Mean It
pythonlikeyoumeanit.com › Module2_EssentialsOfPython › DataStructures_II_Dictionaries.html
Data Structures (Part II): Dictionaries — Python Like You Mean It
A nice syntax for creating a dictionary is to specify key-value pairs inside “curly braces”: {key1:value1, key2:value2, ...}. As an example, let’s construct a dictionary that maps types of foods to “fruit” or “vegetable”. We’ll start by mapping “apple” to “fruit”, and ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-initialize-dictionary-with-multiple-keys
Python | Initialize dictionary with multiple keys - GeeksforGeeks
July 12, 2025 - Otherwise, the function creates a dictionary with a single key-value pair as {keys[0]: value} and then calls itself recursively with the remaining keys keys[1:]. The result of the recursive call is merged with the current key-value pair using ...