Oct-03-2018, 02:01 PM
Here is my code. It gives me the wanted list, but the two "for" loops is a little redundant. I'm wondering if there is simpler way to code it out.
l = ['a','b','a','c','b'] D = {'a':[3,2],'b':[4,5],'c':[1]} L = [] for i in range(len(l)): for k in D: if l[i] == k: L.append(D[k][0]) D[k].remove(D[k][0])Thanks!