You can try this:
a = [('FI', 'SE'), ('SE', 'DK'), ('DK', 'DE'), ('DE', 'PL'), ('PL', 'BY')]
b = [['NL', 'DK', 0], ['NL', 'DE', 0], ['NL', 'BE', 0], ['FI', 'SE', 0.054]]
search1, search2 = ('FI', 'SE')
for val1, val2, val3 in b:
if((val1, val2) == (search1, search2)):
print(val1, val2, val3) # FI SE 0.054
break
else: # caso nao haja break e porque nao foi encontrado
print('não foi encontrado')
STATEMENT
If you want to find all elements of a
in b
, you can:
a = [('FI', 'SE'), ('SE', 'DK'), ('DK', 'DE'), ('DE', 'PL'), ('PL', 'BY')]
b = [['NL', 'DK', 0], ['NL', 'DE', 0], ['NL', 'BE', 0], ['DE', 'PL', 0], ['FI', 'SE', 0.054]]
founds = []
for val1, val2, val3 in b:
if((val1, val2) in a):
founds.append([val1, val2, val3])
print(founds) # [['DE', 'PL', 0], ['FI', 'SE', 0.054]]
STATEMENT
Or:
a = [('FI', 'SE'), ('SE', 'DK'), ('DK', 'DE'), ('DE', 'PL'), ('PL', 'BY')]
b = [['NL', 'DK', 0], ['NL', 'DE', 0], ['NL', 'BE', 0], ['DE', 'PL', 0], ['FI', 'SE', 0.054]]
founds = [[v[0], v[1], v[2]] for v in b if (v[0], v[1]) in a]
print(founds) # [['DE', 'PL', 0], ['FI', 'SE', 0.054]]