title: Remove leading zeros in IP address using Python
body: <p>Remove unnecessary zeros in IP address:</p>
  
  <pre><code>100.020.003.400  -&gt;  100.20.3.400
  001.200.000.004  -&gt;  1.200.0.4
  000.002.300.000  -&gt;  0.2.300.0   (optional silly test)
  </code></pre>
  
  <p>My attempt does not work well in all cases:</p>
  
  <pre><code>import re
  ip = re.sub('[.]0+', '.', ip_with_zeroes)
  </code></pre>
  
  <p>There are similar question but for other languages:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/q/24949991">Perl</a></li>
  <li><a href="https://stackoverflow.com/q/28044684">SQL</a></li>
  </ul>
  
  <p>Please provide solutions for both Python v2 and v3.</p>