Split a given dictionary of lists into list of dictionaries.

In this python dictionary program, we will split a given dictionary of lists into list of dictionaries.

Steps to solve the program
				
					A={'t20':[50,40,30,45], 'odi':[70,10,0,65]}
def dicts(format_):
    result = map(dict, zip(*[[(key, val) for val in value] for key, value in format_.items()]))
    return list(result)

print(dicts(A))
				
			

Output :

				
					[{'t20': 50, 'odi': 70}, {'t20': 40, 'odi': 10}, {'t20': 30, 'odi': 0}, {'t20': 45, 'odi': 65}]
				
			

create a dictionary grouping a sequence of key-value pairs into a dictionary of lists.

remove a specified dictionary from a given list.

Leave a Comment