title: python deleting directly reoccurring values from list
body: <p>I have written a code in javascript that I don't know how to write in python. The use of it is rather simple. There are 2 variables: Buy and Sell. E.g There is Buy, Buy, Sell, Buy, Sell, Sell
  the javascript gives me a new list with Buy,Sell,Buy,Sell</p>
  <pre><code>´´const fs = require('fs');
  
  class Trade {
   price;
  side;
  }
  
  const array = 
  
  console.log('AllTrades:');
  console.log(array);
  
  let trades = [];
  
  for(let i = array.length - 1; i &gt;= 0; i--) {
  let trade = array[i];
  let nextTrade = array[i - 1];
  
  
  
  if(nextTrade) {
  if(trade[0] == &quot;BUY&quot; &amp;&amp; nextTrade[0] == &quot;SELL&quot;) {
      trades[i] = trade;
  }
  if(trade[0] == &quot;SELL&quot; &amp;&amp; nextTrade[0] == &quot;BUY&quot;) {
      trades[i] = trade;
  }
  } else if(trade[0] == &quot;BUY&quot;) {
  trades[i] = trade;
  }
  }
  
  trades = trades.filter(function (i) { return i != undefined;});
  
  console.log('D Trades:');
  for(let i = 0; i &lt; trades.length; i++) {
  console.log(trades[i]);
  }
  
  fs.writeFile('./data/trades.json', JSON.stringify(trades), (err, data) =&gt; {
   if (err) return console.log(err);
  console.log('Trades &gt; trades.txt');
  });  ´´
  </code></pre>