Mapping dictionary value to list

Using a list comprehension:

>>> [dct[k] for k in lst]
[5, 3, 3, 3, 3]

Using map:

>>> [*map(dct.get, lst)]
[5, 3, 3, 3, 3]

Leave a Comment