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}