refs = [('1', 'a', 'string1'), ('1', 'b', 'string2'), ('1', 'c', 'string3'),
    ('1', 'd', 'string3'), ('2', 'a', 'invalid'), ('2', 'b', 'invalid'), (
    '2', 'c', 'string3'), ('2', 'd', 'string3')]
lookup = {ref[:2]: ref[2] for ref in refs}
print(lookup['1', 'd'])
Python: Match two elements in a tuple, return the 3rd