On Wed, 11 Jan 2006 13:58:05 -0000, py <[EMAIL PROTECTED]> wrote:
> Say I have...
> x = "132.00"
>
> but I'd like to display it to be "132" ...dropping the trailing
> zeros...
How about:
if "." in x:
x, frac = x.split(".")
frac = frac.rstrip("0")
if frac:
x = x + "." + frac
Copes if x = "132" too. If there'll always be a decimal point, then you
can leave off the initial "if".
Matt
--
| Matt Hammond
| R&D Engineer, BBC Research & Development, Tadworth, Surrey, UK.
| http://kamaelia.sf.net/
| http://www.bbc.co.uk/rd/
--
http://mail.python.org/mailman/listinfo/python-list