Let's say that your list of dictionaries is called data.

Then you can convert it with the following code:

newdata = [{dic['answer_type']: dic['answer__count']} for dic in data]

If you don't understand this code well, take a look at Python comprehensions

Answer from nyr1o on Stack Overflow
🌐
Compciv
compciv.org › guides › python › fundamentals › dictionaries-overview
Using dictionaries to store data as key-value pairs | Computational Methods in the Civic Sphere at Stanford University
An empty dictionary can be initialized by either using the dict() constructor function, or simply with a pair of curly braces: ... Commas are used to separate the members in a dictionary. But each member consists of a key-value pair.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-dictionary-items-to-values
Python - Convert dictionary items to values - GeeksforGeeks
April 25, 2023 - Input : test_dict = {'Gfg': 1, 'best': 5} Output : [{'key': 'Gfg', 'value': 1}, {'key': 'best', 'value': 5}] Method #1 : Using loop This is brute force way to solve this problem. In this, we need to run a loop to assign each item of dictionary a different value. ... # Python3 code to demonstrate working of # Convert dictionary items to values # Using loop # initializing dictionary test_dict = {'Gfg': 1, 'is': 2, 'best': 3} # printing original dictionary print("The original dictionary : " + str(test_dict)) # Convert dictionary items to values # Using loop res = [] for key, val in test_dict.items(): res.append({"key": key, "value": val}) # printing result print("Converted Dictionary : " + str(res))
🌐
Towards Data Science
towardsdatascience.com › home › data science › how to extract key from python dictionary using value
How to Extract Key from Python Dictionary using Value | Towards Data Science
November 7, 2020 - Method 1 can be slightly modified using a for loop as below: Step 1: Convert dictionary keys and values into lists. Step 2: Iterate through all values in value list to find the required value Step 3: Return the corresponding key from the key list.
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-a-dictionary-to-a-list-in-python
Convert a Dictionary to a List in Python - GeeksforGeeks
April 18, 2026 - The items() method returns all key-value pairs from the dictionary, which can be directly converted into a list.
Find elsewhere
🌐
Jeremy Morgan
jeremymorgan.com › python › how-to-convert-dictionary-to-list
How to Convert a Dictionary to a List in Python
December 22, 2023 - Python dictionaries are a built-in data type in Python, used to store data values in key-value pairs. Lists, on the other hand, are a built-in data type in Python that can hold a collection of data items in a linear sequence. The given code defines a dictionary person and converts it to a list of key-value pairs.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-each-list-element-to-key-value-pair
Convert Each List Element to Key-Value Pair - Python - GeeksforGeeks
July 23, 2025 - During each iteration, the index is added as a key and the corresponding element as the value in the dictionary res. Use zip to pair indices from range(len(li)) with elements from li, creating key-value pairs. Convert the zipped object into ...
Top answer
1 of 5
7

Without having to know the number of keys each dict has in advance, you can iterate through the list, split each string into a key and a value by ': ', appending a new dict to the list if the key is already in the last dict, and keep adding the value to the last dict by the key:

output = []
for key_value in lst:
    key, value = key_value.split(': ', 1)
    if not output or key in output[-1]:
        output.append({})
    output[-1][key] = value

so that given your sample list stored in lst, output would become:

[{'name': 'test1',
  'email': '[email protected]',
  'role': 'test',
  'description': 'test'},
 {'name': 'test2',
  'email': '[email protected]',
  'role': 'test2',
  'description': 'test2'},
 {'name': 'test3',
  'email': '[email protected]',
  'role': 'test3',
  'description': 'test3'}]
2 of 5
3

I am assuming that your order is always the same, i.e., in groups of 4. The idea is to split the strings using : and then create key/value pairs and use nested for loops. The .strip() is to get rid of whitespace

lst = ['name: test1', 'email: [email protected]', 'role: test', 'description: test', 
       'name: test2', 'email: [email protected]', 'role: test2', 'description: test2', 
       'name: test3', 'email: [email protected]', 'role: test3', 'description: test3']

answer = []

for i in range(0, len(lst), 4):
    dic = {}
    for j in lst[i:i+4]:
        dic[j.split(':')[0]] = j.split(':')[1].strip() 
    answer.append(dic)

# [{'name': 'test1',  'email': '[email protected]',  'role': 'test',  'description': 'test'},
    #  {'name': 'test2',  'email': '[email protected]',  'role': 'test2',  'description': 'test2'},
    #  {'name': 'test3',  'email': '[email protected]',  'role': 'test3',  'description': 'test3'}]

A list comprehension would look like

answer = [{j.split(':')[0]:j.split(':')[1].strip() for j in lst[i:i+4]} for i in range(0, len(lst), 4)]
🌐
Quora
quora.com › How-do-I-convert-list-of-key-value-values-to-dictionary-in-Python
How to convert list of 'key:value' values to dictionary in Python - Quora
Answer (1 of 9): dict = {k:v for k,v in (x.split(':') for x in list) } * If you want the conversion to int, you can replace k:v with int(k):int(v) ** Note: The general convention and advice is to avoid using map function, and instead use comprehension. *** Calling variables "dict" or "list" sh...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-key-value-string-to-dictionary
Python - Convert key-value String to dictionary - GeeksforGeeks
April 28, 2023 - Sometimes, while working with Python strings, we can have problems in which we need to convert a string's key-value pairs to the dictionary. This can have applications in which we are working with string data that needs to be converted.
🌐
Google
developers.google.com › google for education › python › python dict and file
Python Dict and File | Python Education | Google for Developers
## Note that the keys are in a random order. for key in dict: print(key) ## prints a g o ## Exactly the same as above for key in dict.keys(): print(key) ## Get the .keys() list: print(dict.keys()) ## dict_keys(['a', 'o', 'g']) ## Likewise, there's a .values() list of values print(dict.values()) ## dict_values(['alpha', 'omega', 'gamma']) ## Common case -- loop over the keys in sorted order, ## accessing each key/value for key in sorted(dict.keys()): print(key, dict[key]) ## .items() is the dict expressed as (key, value) tuples print(dict.items()) ## dict_items([('a', 'alpha'), ('o', 'omega'),
🌐
Quora
quora.com › How-can-I-swap-a-Python-dictionary-s-keys-and-values
How to swap a Python dictionary’s keys and values - Quora
Answer (1 of 9): Using comprehensions is actually the best way to do it. Example: Your dictionary: Swapped dictionary:
🌐
GeeksforGeeks
geeksforgeeks.org › python › add-a-keyvalue-pair-to-dictionary-in-python
Add a key value pair to Dictionary in Python - GeeksforGeeks
This is the simplest way to add or update a key-value pair in a dictionary. We access the dictionary by specifying the key inside square brackets and assign the corresponding value.
Published: July 11, 2025
🌐
Python Pool
pythonpool.com › home › tutorials › convert a python dictionary to a list: keys, values, and items
Convert a Python Dictionary to a List: Keys, Values, and Items
July 13, 2026 - Dictionary keys: A mapping, keys view, ordering, and iteration. items() gives key-value pairs. Convert it to a list when you need a reusable list of two-item tuples.
🌐
AskPython
askpython.com › python › string › dictionary-to-a-string
How to convert a dictionary to a string in Python? - AskPython
July 1, 2021 - In this method of converting a dictionary to a string, we will simply access the keys of the dictionary by iterating through the dictionary object using a for loop. Then we access the value corresponding to each key and add the key: value pair ...