is it possible to apply list/dictionary comprehension to the following code to have ["abc", "ab", "cd"]
tk = {}
tk[1] = ["abc"]
tk[2] = ["ab", "cd"]
tk[3] = ["ef", "gh"]
t = (1, 2)
combined = []
combined.append(tk[i]) for i in t #does not work. note, not all tk values are used, this is based on t.
I could think of
ll = [tk[i] for i in t]
, then this turns to be flatten list out of lists. so
ll = [tk[i] for i in t]
[item for sublist in ll for item in sublist]
but this is not one-liner. I wonder if there is better way.