Formatting floats in Python without superfluos zeros
- by TarGz
How to format a float so it does not containt the remaing zeros? In other words, I want the resulting string to be as short as possible..?
Like:
3 -> "3"
3. -> "3"
3.1 -> "3.1"
3.14 -> "3.14"
3.140 -> "3.14"