Ask Your Question

Revision history [back]

For every sublist of Yc and every element a in X, search a in the sublist and append the corresponding element b in Y (X and Y are aligned with zip):

Yc = []
for j in Xc:
    l = []
    for (a,b) in zip(X,Y):
        if a in j:

Note that this way, the elements in the sublists are not sorted in the same order (but i guess you do not mind given the description).