Write a Python3 code to demonstrate working of Extract dictionaries with values sum greater than K
Topic: Write a Python3 code to demonstrate working of Extract dictionaries with values sum greater than K
Solution
test_list = [{"Gfg" : 4, "is" : 8, "best" : 9}, {"Gfg" : 5, "is": 8, "best" : 1}, {"Gfg" : 3, "is": 7, "best" : 6}, {"Gfg" : 3, "is": 7, "best" : 5}] print("The original list : " + str(test_list)) K = 15 res = [] for sub in test_list: sum = 0 for key in sub: sum += sub[key] if sum > K: res.append(sub) print("Dictionaries with summation greater than K : " + str(res))
List all Python Programs