title: How to match element of one list with exactly one other element in another list in python?
body: <p>I have two lists:
  a=[1,2]
  b=[1,2,1,1,1,2,2]
  How do i match an element of list a with exactly the same element in list b only once.
  I tried the code:</p>
  
  <pre><code>for unit in a:
      for nit in b:
          if unit==nit:
              print(unit,nit)
  </code></pre>
  
  <p>But it matches element in list a with all the similar matches with elements in list b. I need only a single match and not multiple matches.   </p>
  
  <p>So i tried removing the element to prevent further matches, as in the code:</p>
  
  <p>I tried the code:</p>
  
  <pre><code>for unit in a:
      for nit in b:
          if unit==nit:
              print(unit,nit)
              a.remove(unit)
  </code></pre>
  
  <p>But it returns error.</p>