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
Answers:
The easiest way to do this is with zip()
, then create the dict
from a list of tuples:
dictionary = dict(zip(keys, values))
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
The easiest way to do this is with zip()
, then create the dict
from a list of tuples:
dictionary = dict(zip(keys, values))