Python: Convert list to list of dictionaries
Convert List to List of Dictionaries
Write a Python program to convert a list to a list of dictionaries.
Sample Solution:
Python Code:
Sample Output:
[{'color_name': 'Black', 'color_code': '#000000'}, {'color_name': 'Red', 'color_code': '#FF0000'}, {'color_nam e': 'Maroon', 'color_code': '#800000'}, {'color_name': 'Yellow', 'color_code': '#FFFF00'}]
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to create a list of dictionaries with default keys and dynamic values.
- Write a Python program to convert two lists into a list of dictionaries.
- Write a Python program to transform a list of tuples into a list of dictionaries.
- Write a Python program to merge a list of dictionaries based on a common key.
Go to:
Previous: Write a Python program to print a nested lists (each list on a new line) using the print() function.
Next: Write a Python program to sort a list of nested dictionaries.
Python Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.