Need help removing trailing zeros
Joshua Landau
joshua.landau.ws at gmail.com
Wed Jun 26 18:14:05 EDT 2013
On 26 June 2013 23:02, <bandcamp57 at gmail.com> wrote:
> Hello, i'm making a calculator and I want to be able to use decimals but I don't like it when it comes out as ex.12.0 when it should be 12. I tried using .rstrip("0".rstrip(".") but that never seemed to work. If anyone has a solution please let me know, all help is greatly appreciated.
>
> Code:
<LOTS 'O CODE>
Was that really necessary?
All you needed to give use was "print(1.0)"; why post so much?
Either:
"{:g}".format(1.0)
or, if you hate scientific notation:
"{:f}".format(1.0).rstrip(".0")
More information about the Python-list
mailing list