The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Pair corresponding items in the two lists with zip(), then pass those pairs to dict():
keys = ["name", "age"]
values = ["Ada", 36]
result = dict(zip(keys, values))
print(result) # {'name': 'Ada', 36}
How the conversion works
zip(keys, values) pairs items by position: the first key with the first value, the second key with the second value, and so on. The resulting pairs are passed to dict(), which creates a dictionary from an iterable of key-value pairs.
As an Amazon Associate I earn from qualifying purchases.
For example:
keys = ["color", "size", "in_stock"]
values = ["blue", "medium", True]
product = dict(zip(keys, values))
# {'color': 'blue', 'size': 'medium', 'in_stock': True}
This uses Python’s built-in zip() and dict() functions; no import is needed. The Python documentation describes zip() and dictionary construction.
Recommended Free Tools
What happens when the lists have different lengths?
By default, zip() stops as soon as the shorter iterable runs out. Any extra items in the longer list are ignored, so the resulting dictionary may omit data without raising an error.
#1 Best Overall
Choose the behavior that matches your data:
| Situation | Approach | Result |
|---|---|---|
| The lists should have equal lengths | dict(zip(keys, values, strict=True)) |
On Python 3.10 and later, raises ValueError if their lengths differ. The strict parameter was added in Python 3.10. |
| Unequal lengths are acceptable, and unmatched items should be omitted | dict(zip(keys, values)) |
Pairs items up to the end of the shorter input. |
| Unequal lengths are acceptable, and missing entries should be padded | itertools.zip_longest() |
Pairs through the end of the longer input, filling missing items with a value you specify; the default fill value is None. |
For example, to pad unmatched positions with None:
from itertools import zip_longest
keys = ["name", "age", "city"]
values = ["Ada", 36]
result = dict(zip_longest(keys, values))
# {'name': 'Ada', 'age': 36, 'city': None}
Choose padding carefully: if the shorter list supplies keys, a padded None key can become an actual dictionary key.
What if a key appears more than once?
Dictionary keys must be unique in the result. If the input key list contains duplicates, each later pair replaces the value from the earlier pair for that key:
Rank #2
keys = ["color", "color"]
values = ["blue", "green"]
result = dict(zip(keys, values))
# {'color': 'green'}
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.When to use a dictionary comprehension
Use a comprehension when each paired value needs a transformation or when you want to filter pairs. It follows the same positional pairing and default shortest-input behavior as zip():
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
keys = ["name", "score", "level"]
values = ["Ada", 95, 4]
result = {
key: value
for key, value in zip(keys, values)
if key != "level"
}
# {'name': 'Ada', 'score': 95}
If no transformation or filtering is needed, dict(zip(keys, values)) is the direct option.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




