title: Remove duplicate spaces from string except new line character (\n) in Python
body: <p>I have a string and I want to remove duplicate spaces from that. But my string has a new line character <code>\n</code> and after doing <a href="https://stackoverflow.com/a/8270146/14362977">this</a>, this character also is deleted.<br />
  Output of this:</p>
  <pre><code>s = 'A B     C  D \n EF   G'
  print(s)
  s = &quot; &quot;.join(s.split())
  print(s)
  </code></pre>
  <p>is as follows:</p>
  <pre><code>A B     C  D 
   EF   G
  ------------
  A B C D EF G
  </code></pre>
  <p>But I do not want to remove this character. The desired output:</p>
  <pre><code>A B C D
   EF G
  </code></pre>