how to improve this simple block of code
Mike Meyer
mwm at mired.org
Wed Jan 11 10:02:18 EST 2006
"py" <codecraig at gmail.com> writes:
> Say I have...
> x = "132.00"
> but I'd like to display it to be "132" ...dropping the trailing
> zeros...I currently try this
The two-strip solution is cleaner, but:
> if x.endswith("0"):
> x = x[:len(x)-1]
x = x[:-1]
or
del x[-1]
both improve that one statement.
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list