def drop_trailing_zeros ( num ) : txt = '%f' % ( num ) txt = txt . rstrip ( '0' ) if txt . endswith ( '.' ) : txt = txt [ : - 1 ] return txt
python keep trailing zero
Drops the trailing zeros in a float that is printed .
def drop_trailing_zeros(num):
    """
    Drops the trailing zeros in a float that is printed.
    """
    txt = '%f' %(num)
    txt = txt.rstrip('0')
    if txt.endswith('.'):
        txt = txt[:-1]
    return txt