Convert two lists into a dictionary


Tue Apr 21 2020 11:45:29 GMT+0000 (Coordinated Universal Time)

Saved by @TrickyMind #python #python #lists #dictionary

keys, values)) # {'a': 2, 'c': 4, 'b': 3}
#make a function: def is the keyword for the function:
def to_dictionary(keys, values):
#return is the keyword that tells program that function has to return value   
return dict(zip(keys, values))
# keys and values are the lists:
keys = ["a", "b", "c"]   
values = [2, 3, 4]

This code is used to convert two lists into a dictionary.