title: How to format a float with a maximum number of decimal places and without extra zero padding?
body: <p>I need to do some decimal place formatting in python. Preferably, the floating point value should always show at least a starting 0 and one decimal place. Example:</p>
  
  <pre><code>Input: 0
  Output: 0.0
  </code></pre>
  
  <p>Values with more decimal places should continue to show them, until it gets 4 out. So:</p>
  
  <pre><code>Input: 65.53
  Output: 65.53
  
  Input: 40.355435
  Output: 40.3554
  </code></pre>
  
  <p>I know that I can use {0.4f} to get it to print out to four decimal places, but it will pad with unwanted 0s. Is there a formatting code to tell it to print out up to a certain number of decimals, but to leave them blank if there is no data? I believe C# accomplishes this with something like:</p>
  
  <pre><code>floatValue.ToString("0.0###")
  </code></pre>
  
  <p>Where the # symbols represent a place that can be left blank.</p>