I have Two list:
L = ['A','B','C']
L2 = ['A', 'B', ('B', 'A'), 'C']
I would create a single list with the following element:
L3 = ['A', ('B', 'A'), 'C']
Every time an element in the list L is present in more element in the L2 list I would pick the longest one. Important, Only if B Is at the first place of the tuple
I tried the following code: the following code
temp_length = 0
for d in L:
for d2 in L2:
if d in d2 and temp_length<len(d2):
temp_op = d
L3.append(temp_op)
But is not adding ('B','A') instead of 'B'