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 can be empty or there can be no common elements - in this case None is fine.
I need this to show python to someone who is new to it, so the simpler the better.
UPD: the order is not important for my purposes, but let's assume I'm looking for the first element in x that also occurs in y.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…