Python Practice › List Programs › Program 84
Dictionary from two lists
Write a Python program to create a dictionary from a list of keys and a list of values.
Input
["a", "b", "c", "d", "e"], [234, 123, 456, 343, 223]
Output
{'a': 234, 'b': 123, 'c': 456, 'd': 343, 'e': 223}Approach
dict(zip(keys, values)).
Solution
keys = ["a", "b", "c", "d", "e"]values = [234, 123, 456, 343, 223]print(dict(zip(keys, values)))Output
{'a': 234, 'b': 123, 'c': 456, 'd': 343, 'e': 223}Learn the concept
New to this topic? Read the lesson, then come back.