Use zip
to create a list of (key, value)
tuples, then apply the dict
constructor:
keys = ['a', 'b', 'c']
values = [1, 2, 3]
dictionary = dict(zip(keys, values))
print(dictionary)
Output:
{'a': 1, 'b': 2, 'c': 3}
More Related Contents:
- How to name a file using a value in a list in a dictionary?
- How do I sort a list of dictionaries by a value of the dictionary?
- Access nested dictionary items via a list of keys?
- How do I initialize a dictionary of empty lists in Python?
- How to return dictionary keys as a list in Python?
- How do I merge a list of dicts into a single dict?
- Grouping Python dictionary keys as a list and create a new dictionary with this list as a value
- How do I initialize a dictionary of empty lists in Python?
- In Python, when to use a Dictionary, List or Set?
- Pandas DataFrame to List of Dictionaries
- python filter list of dictionaries based on key value
- How can I access the nested data in this complex JSON, which includes another JSON document as one of the strings?
- How do I combine two lists into a dictionary in Python? [duplicate]
- Converting list of tuples into a dictionary
- Merging dictionary value lists in python
- join two lists of dictionaries on a single key
- How do I serialize a Python dictionary into a string, and then back to a dictionary?
- Python – sum values in dictionary
- Setting a value in a nested Python dictionary given a list of indices and value
- Convert list of strings to dictionary
- Using a dict to translate numbers to letters in python
- How can I make a dictionary (dict) from separate lists of keys and values?
- How can I avoid “RuntimeError: dictionary changed size during iteration” error?
- Changing one dict changes all dicts in a list of dicts [duplicate]
- Appending to list in Python dictionary [duplicate]
- Creating a dictionary with list of lists in Python
- Mapping dictionary value to list
- How to extract all values from a dictionary in Python?
- Comparing 2 lists consisting of dictionaries with unique keys in python
- How to create a nested dictionary from a list in Python?