Python Practice › List Programs › Program 84

Dictionary from two lists

EasyList Programs · 84 of 100

Write a Python program to create a dictionary from a list of keys and a list of values.

Advertisement
Input
["a", "b", "c", "d", "e"], [234, 123, 456, 343, 223]
Output
{'a': 234, 'b': 123, 'c': 456, 'd': 343, 'e': 223}

Approach

  1. dict(zip(keys, values)).

Solution

Python
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.

More list programs

← All 100 List Programs

Leave a Comment