title: python: Delete consecutively repeated words in sentence
body: <p>I have the following sentence:</p>
  
  <pre><code>s = "Et puis j'obtiens : [voir écran] [voir écran] [voir écran] [voir écran] [voir écran] [voir écran] [voir écran] [voir écran] [voir écran] [voir écran] Donc, ça veut dire que la suite de nombres réels"
  </code></pre>
  
  <p>As you can see [voir écran] appears to often. I just want to have it appear ones.</p>
  
  <p>I tried (similar to <a href="https://datascience.stackexchange.com/questions/34039/regex-to-remove-repeating-words-in-a-sentence">https://datascience.stackexchange.com/questions/34039/regex-to-remove-repeating-words-in-a-sentence</a>) :</p>
  
  <pre><code>from itertools import groupby
  
  
  no_dupes = ([k for k, v in groupby(sent_clean.split())])
  
  
  # Put the list back together into a sentence
  groupby_output = ' '.join(no_dupes)
  print('No duplicates:', groupby_output)
  </code></pre>
  
  <p><strong>...but it did not work.</strong></p>