formatting a number as percentage

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Wed Feb 24 03:03:51 CET 2010


In message <6819f2f8-7a9e-4ea4-a936-c4e00394bd30 at g28g2000yqh.googlegroups.com>, vsoler wrote:

> I'm trying to print .7 as 70%

Just to be perverse:

    (lambda x : (lambda s : s[:s.index(".")] + s[s.index(".") + 1:] + "%")("%.2f" % x).lstrip("0"))(.7)

:)



More information about the Python-list mailing list