title: How do I trim whitespace from a string?
body: <p>How do I remove leading and trailing whitespace from a string in Python?</p>
  <pre><code>&quot; Hello world &quot; --&gt; &quot;Hello world&quot;
  &quot; Hello world&quot;  --&gt; &quot;Hello world&quot;
  &quot;Hello world &quot;  --&gt; &quot;Hello world&quot;
  &quot;Hello world&quot;   --&gt; &quot;Hello world&quot;
  </code></pre>