title: Identify distinct elements in a list and map it to a corresponding index in another list in python
body: <p>I have 2 different lists:</p>
  
  <pre><code>l1 = ['a','b','a','e','b','c','a','d']
  l2 = ['t1','t2','t3','t4','t5','t6','t7','t8']
  </code></pre>
  
  <p>The lengths of <code>l1</code> and <code>l2</code> will always be the same. They're in fact logical mappings - each item in <code>l1</code> corresponds to a value in <code>l2</code>.</p>
  
  <p>I wanted to identify distinct elements in <code>l1</code>. I did that using <code>set</code> and <code>list comprehension</code> as follows:</p>
  
  <pre><code>used = set()
  distl1 = [x for x in l1 if x not in used and (used.add(x) or True)]
  </code></pre>
  
  <p>Here, the output will be:</p>
  
  <pre><code>distl1 = ['a','b','e','c','d']
  </code></pre>
  
  <p>which is nothing but the first occurrence of every distinct element.</p>
  
  <p>Now, how do I build a list <code>distl2</code> so that I get the output as the value in <code>l2</code> that corresponds to the first occurrence's value i.e., <code>distl1</code>?</p>
  
  <pre><code>distl2 = ['t1','t2','t4','t6','t8']
  </code></pre>