Write a program to convert a dictionary value list to dictionary list and prints it.


Topic: Write a program to convert a dictionary value list to dictionary list and prints it.

Solution

test_list = [{'END' : [5, 6, 5]}, {'is' : [10, 2, 3]}, {'best' : [4, 3, 1]}] 
res =[{} for idx in range(len(test_list))] 
idx = 0
for sub in test_list: 
	for key, val in sub.items(): 
		for ele in val: 
			res[idx][key] = ele 
			idx += 1
		idx = 0
print("Records after conversion : " + str(res))



List all Python Programs