title: Matching character lists of unequal length
body: <p>I want to match two lists from which one list is smaller while other is a bigger one. If a match occurs between two lists then put the matching element in a new list at the same index instead of putting it another index. You can understand my question from the code given below:</p>
  
  <pre><code>list1=['AF','KN','JN','NJ']
  list2=['KNJ','NJK','JNJ','INS','AFG']
  matchlist = []
  smaller_list_len = min(len(list1),len(list2))
  
  
  for ind in range(smaller_list_len):
      elem2 = list1[ind]
      elem1 = list2[ind][0:2] 
  
      if elem1 in list2:
         matchlist.append(list1[ind])
  </code></pre>
  
  <p><strong><em>Obtained output</em></strong></p>
  
  <pre><code>&gt;&gt;&gt; matchlist
  ['KNJ', 'NJK', 'JNJ']
  </code></pre>
  
  <p><strong><em>Desired Output</em></strong></p>
  
  <pre><code>&gt;&gt;&gt; matchlist
  ['AFG', 'KNJ', 'JNJ', 'NJK']
  </code></pre>
  
  <p>Is there a way to get the desired output?</p>