title: Deleting values in one column corresponding to another using Python
body: <p>I save the data in a csv file in two columns, <code>T</code> and <code>L1</code>. Then I remove some values from <code>L1</code> using <code>L2</code> and generate a new list, <code>L3</code>. Now I would like to save the values of <code>T</code> corresponding to <code>L3</code>. The current and desired outputs are attached.</p>
  <pre><code>import csv 
  T=[1,2,3,4,5]
  L1=[(0, 0), (0, 7), (3, 2), (7, 9), (7, 0)]
  L2=[(0, 0), (0, 7), (3, 2)]
  L3 = [i for i in L1 if i not in L2]
  #print(L3)
  header1 = ['T','Indices']
  with open('Indices1234.csv', 'w') as f:
      writer = csv.writer(f)
  
      # write the header
      writer.writerow(header1)
  
      # write the data
      writer.writerows(zip(T,L1))    
  
  
  header2 = ['T','Indices']
  with open('Indices123.csv', 'w') as f:
      writer = csv.writer(f)
  
      # write the header
      writer.writerow(header2)
  
      # write the data
      writer.writerows(zip(T,L3))   
  </code></pre>
  <p>Current output:</p>
  <p><img src="https://i.stack.imgur.com/fI1sa.png" alt="Current output" /></p>
  <p>Desired output</p>
  <p><img src="https://i.stack.imgur.com/mmwRY.png" alt="Desired output" /></p>