I want to use dictionary.get method but to return nothing (not None) when a key is missing, is it possible without "filtering" the output:
d = {1:'a', 2:'b'}
vals = [1,2,3]
#I want the output to look like:
newvals = [d[v] for v in vals if v in d]
#newvals
#['a', 'b']
#But this will return default value which is None:
newvals2 = [d.get(v) for v in vals]
#>>> newvals2
#['a', 'b', None]
#(I know I can add this, but do I have to?)
#newvals2 = [val for val in newvals if val]
#['a', 'b']