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

Better Stack Team
Updated on February 17, 2023

You can create a Python dictionary from two separate lists, where the first list contains keys and the second list contains values using the zip function.

Here is an example of this in action:

 
# List of keys
keys = ['a', 'b', 'c']

# List of values
values = [1, 2, 3]

# Zip the keys and values and create a dictionary
dictionary = dict(zip(keys, values))
print(dictionary) 
# Output: {'a': 1, 'b': 2, 'c': 3}
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →