> How about: > > if "." in x: > x, frac = x.split(".") > frac = frac.rstrip("0") > if frac: > x = x + "." + frac
Or simpler still: if "." in x: x = x.rstrip("0") x = x.rstrip(".") More concise, but slightly less readable IMO: if "." in x: x = x.rstrip("0").rstrip(".") -- | 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