In Python. How to make the elements of the first list be the keys, and the elements of the second list the values ​of the dictionary

Question:

help me please
In Python. How to make the elements of the first list be the keys, and the elements of the second list the values ​​of the dictionary

keys = []  # first list


values = [] # second list


dictionary = {} # our dict
Asked By: Str1ke

||

Answers:

The easiest way to do this is with zip(), then create the dict from a list of tuples:

dictionary = dict(zip(keys, values))
Answered By: Code-Apprentice
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.