[Tutor] cut all decimal places with zeros

Kent Johnson kent37 at tds.net
Tue Apr 15 03:43:35 CEST 2008


Tim Michelsen wrote:
> Hello,
> how can I suppress the decimal places for (only those) numbers whos 
> decimal places are zero (0)?

I don't know how to do this with just string formatting but I think
('%.4f' % n).rstrip('.0')
will do what you want.

Kent


More information about the Tutor mailing list