Write Python3 code to demonstrate working of Convert Dictionaries List to Order Key Nested dictionaries Using dictionary comprehension + enumerate()


Topic: Write Python3 code to demonstrate working of Convert Dictionaries List to Order Key Nested dictionaries Using dictionary comprehension + enumerate()

Solution

test_list = [{"Gfg" : 3, 4 : 9}, {"is": 8, "Good" : 2}, {"Best": 10, "CS" : 1}] 
print("The original list : " + str(test_list)) 
res = {idx : val for idx, val in enumerate(test_list)} 
print("The constructed dictionary : " + str(res)) 



List all Python Programs