list indexes

0

My two initial lists have repeated values: B_I = [Cab, Bou, Bou, RFF, RF1, Rf2, Cor] Ba_F = [Bou, Zez1, Zez2, Praca, Sro, Sro, Falag]

I deleted the repeats, keeping: Final = [Cab, Bou, RFF, RF1, Rf2, Color, Zez1, Zez2, Praca, Sro, Falag]

I needed to get to the end with 2 index lists of occurrences in each of the initial lists, like:

B_I_final = [0,1,1,2,3,4,5] Ba_F_final = [1,6,7,8,9,9,10]

I tried this: No_I = [] for a in range (0, len (Ba_I)):     for b in range (0, len (Final)):         if Ba_I [a] == Final [b]:             No_I.append (Final.index (b))         else:             No_I.append () I do not know how to do it in the else, ie in the situation where the index in the initial list differs from the index in the final list I wanted it to take the index value of that element in the final list .. Does anyone know how to do this?

    
asked by anonymous 20.04.2016 / 17:34

1 answer

0
>>> B_I = ['Cab', 'Bou', 'Bou', 'RFF', 'RF1', 'Rf2', 'Cor']
>>> Ba_F = ['Bou', 'Zez1', 'Zez2', 'Praca', 'Sro', 'Sro', 'Falag']
>>> Final = list(set(B_I+Ba_F))
>>> B_I_final = [Final.index(i) for i in B_I]
>>> Ba_F_final = [Final.index(i) for i in Ba_F] 
    
20.04.2016 / 19:04