dictionary = {"raj": 2, "striver": 3, "vikram": 4}
myvals = [2,4]
Need to get ['raj', 'vikram'] as a list filtering above dictionary using myvals list
tried
result = [dictionary[k] for k in [2, 4]]
result = [dictionary[k] for k in myvals]
CodePudding user response:
[k for k, v in dictionary.items() if v in myvals]