x = [8,2,3,4,5] y = [6,3,7,2,1]
How to find out the first common element in two lists (in this case, \"2\") in a concise and elegant way? Any list
def first_common_element(x,y): common = set(x).intersection(set(y)) if common: return x[min([x.index(i)for i in common])]