I have a dictionary dic
with this key and value pair: (note: this dic
is bijective, i.e: one-to-one mapping)
dic = {
0: 0,
30: 1,
35: 2,
42: 3,
53: 4,
54: 5,
55: 6,
81: 7,
83: 8,
95: 9,
99: 10
}
In my source code, there is list L
which is generated from a particular computation. Values in L
are actually associated with dic
values. So, based on dic
, I want this L
list:
L = [0, 0, 7, 2, 2, 1, 9]
to be converted to key values from dic
. This is the desired output out
:
out = [0, 0, 81, 35, 35, 30, 95]
What kind of list comprehension can I use to achieve the desired output?