Is there a Pythonic way of returning the first item in a list which is also an item in another list? At the moment I'm doing it using brute force and ignorance:
def FindFirstMatch(a, b):
"""
Returns the first element in a for which there is a matching
element in b or None if there is no match
"""
for item in a:
if item in b:
return item
return None
So FindFirstMatch(['Fred','Wilma','Barney','Betty'], ['Dino', 'Pebbles', 'Wilma', 'Bambam'])
returns 'Wilma'
but I wondered if there was a more elegant/efficient/Pythonic way.