title: How to best replace multiple whitespaces by one (in python)?
body: <p>In python I have, for example, the following string: </p>
  
  <pre><code>a = "Sentence  with     weird    whitespaces"
  </code></pre>
  
  <p>I want the same string with extended whitespaces replaced by just one, so the final string would read</p>
  
  <pre><code> 'Sentence with weird whitespaces'
  </code></pre>
  
  <p>I found a solution myself, but is there a better/shorter one? </p>
  
  <pre><code>' '.join([x for x in a.split(' ') if len(x)&gt;0])
  </code></pre>