Write a Python program to Convert two lists into a dictionary


The program is written in Python and it creates a dictionary called "res" using the "zip" function and the lists "keys" and "values". The lists "keys" and "values" are both lists containing five elements each. "keys" contains the keys for the dictionary, and "values" contains the corresponding values.

The "zip" function combines the elements of the two lists "keys" and "values" into a single list of tuples, where each tuple consists of a key-value pair. For example, the first tuple would be ("One", 1), the second would be ("Two", 2), and so on. The dict() function is then used to convert the list of tuples into a dictionary, and the resulting dictionary is assigned to the variable "res".

Source Code

keys = ["One", "Two", "Three", "Four", "Five"]
values = [1, 2, 3, 4, 5]
 
res = dict(zip(keys, values))
print(res)

Output


{'One': 1, 'Two': 2, 'Three': 3, 'Four': 4, 'Five': 5}