Write a program to print keys in a dictionary whose values are greater than a given input.


Topic: Write a program to print keys in a dictionary whose values are greater than a given input.

Solution

test_dict = {'tsai' : 4, 'random_key' : 2, 'foo' : 3, 'bar' : 'END'} 
K = 3
res = {key : val for key, val in test_dict.items() 
                   if type(val) != int or val > K} 
print("Values greater than K : ", res.keys())



List all Python Programs