title: How to find the common elements of two lists?
body: <p>I'm trying to find the common elements of two lists using python 3, and have a new list with the common elements appearing only once. This is what I have so far:</p>
  
  <pre><code>lengtha = len(lista);
  lengthb = len(listb);
  
  identical = [];
  checker = 0;
  
  for i in range (0, lengtha-1):
      for j in range (0, lengthb-1):
          if lista[i] == listb[j]:
              length = len(identical);
              for h in range (0, length-1):
                  if lista[i] == identical[h]:
                  checker = 1;
              if checker == 0:
                  identical.append(list[i]);
              checker = 0;
  </code></pre>
  
  <p>When I tried it with the lists</p>
  
  <pre><code>lista = ['hello', 'cat', 'dog', 'dog']
  listb = ['hello', 'cat', 'cat', 'mouse', 'whale', 'whale', 'elephant', 'whale', 'elephant', 'dog', 'dog']
  </code></pre>
  
  <p>The result was <code>['hello','cat','cat','dog']</code>. I can't figure out why <code>'cat'</code> shows up twice and other duplicated animals didn't.</p>