With dictionary:
dictionary={1:'One', 2:'Two', 3:'Three', 4:'Four', 5:'Five'}
and a list of known keys:
keys=[2, 4]
What is the fastest shortest way to retrieve dictionary values?
The goal is to replace this code:
result=[]
for key in dictionary:
if not key in keys: continue
result.append(dictionary[key])