Write a program to print the values of a given extraction key from a list of dictionaries.


Topic: Write a program to print the values of a given extraction key from a list of dictionaries.

Solution

test_list = [{"Gfg" : 3, "b" : 7},  
             {"is" : 5, 'a' : 10},  
             {"Best" : 9, 'c' : 11}]  
K = 'Best'
res = [sub[K] for sub in test_list if K in sub][0]   
print("The extracted value : " + str(res))



List all Python Programs