Python: Split a given dictionary of lists into list of dictionaries using map function
15. Dict to List Map
Write a Python program to split a given dictionary of lists into list of dictionaries using the map function.
Sample Solution:
Python Code:
Sample Output:
Original dictionary of lists: {'Science': [88, 89, 62, 95], 'Language': [77, 78, 84, 80]} Split said dictionary of lists into list of dictionaries: [{'Science': 88, 'Language': 77}, {'Science': 89, 'Language': 78}, {'Science': 62, 'Language': 84}, {'Science': 95, 'Language': 80}]
For more Practice: Solve these Related Problems:
- Write a Python program to convert a dictionary of lists into a list of dictionaries by mapping over the zipped values.
- Write a Python program to use map to iterate over a dictionary of lists and form individual dictionaries for each index.
- Write a Python program to apply map with a lambda that reconstructs dictionaries from a dictionary of lists.
- Write a Python program to convert a dictionary of lists into a list of dictionaries while preserving keys, using map.
Go to:
Previous: Write a Python program to interleave two given list into another list randomly using map() function.
Next: Write a Python program to convert a given list of strings into list of lists using map function.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.