turn two lists to dictionaries code example
Example 1: dictionary from two lists
>>> keys = ['a', 'b', 'c']
>>> values = [1, 2, 3]
>>> dictionary = dict(zip(keys, values))
>>> print(dictionary)
{'a': 1, 'b': 2, 'c': 3}
Example 2: convert two lists to a single dictionary python
key_list = ['red', 'green', 'blue']
value_list = [1, 2, 3]
my_dict = {}
for key in key_list:
for value in value_list:
my_dict[key] = value
value_list.remove(value)
break
print(my_dict)
Example 3: convert string to list of dictionaries
import ast
ast.literal_eval(string_data)