title: First common element from different lists of numbers
body: <p>I am trying to find the first common number (FCN) from e.g. 5 individual number lists. <strong>For example the 5 number lists are these ones</strong>: </p>
  
  <pre><code>list_1 = [13579875, 25732, 3541, 56732, 1567, 20546, 10, 68971]
  list_2 = [1856721, 25724, 3541, 56732, 1567, 20546, 10, 68971]
  list_3 = [2354074, 25732, 3541, 56732, 1567, 20546, 10, 68971]
  list_4 = [533878, 651, 658, 8654,1357, 1254, 9, 68971]
  list_5 = [567432, 25732, 3541, 56732, 1567, 20546, 10, 68971]
  </code></pre>
  
  <p>So ultimately, I want to be taking one pair of lists at a time and checking what is their FCN. In my mind, I would need to find the index of the first match. So between list_1 and list_2, the FCN is 3541 (index 2 for list_1 and index 2 for list_2 as well). Then I would have to compare list_1 with list_3 and find their FCN which is 25732. At any point, I would have to remember the FCN from the comparison of the list pairs. Ultimate purpose for building a tree that would show the association of the numbers. Then after comparing list_1 with all lists up to list_5, I would then start comparing list_2 with all other lists, until all possible comparisons were done. </p>
  
  <p>I thought of solving it by having two for loops but I am not able to combine them into one function. This is all I have: </p>
  
  <pre><code>compare_lists = []
  for i in list_1: 
         if i in list_2:
             compare_lists.append(1)
         else: 
             compare_lists.append(0)
  print compare_lists
  </code></pre>
  
  <p>And for the part that I find the index of the FCN, I have this: </p>
  
  <pre><code>indexFCN_a = ""
  indexFCN_b = ""
  for a in list_1:
      if a in list_2: 
          indexFCN_a = list_1.index(a)
          indexFCN_b = list_2.index(a)
          print indexFCN_a
          break
  </code></pre>
  
  <p><strong>Obviously, one of my main problems, is that these need to be in one function and I am not quite sure on how to do this correctly.</strong> I tried, but it's not quite what it should be. <strong>Can you give an answer where this is in a function?</strong> Any help would be greatly appreciated. </p>
  
  <p>I am sure though that this task can be solved much more efficiently so if you have any ideas please share them. Please keep in mind that the ultimate purpose store the FCN for each comparison, for building a tree that would show the number associations.</p>
  
  <p>Please see comments for further explanation. 
  Also: how could I be keeping track to the number of times an element is the FCN? So the expected output for this question is: 3541 - 3 times, 25732 - 3 times, 68971 - 4 times. </p>