On 2006-03-23, Michael Yanowitz <[EMAIL PROTECTED]> wrote: >> With that terse description and the subject line I would interpret the >> OP like so: >> >>>>> print re.sub(".*\.",".","0.666") >> .666 >>>>> print re.sub(".*\.",".","123.666") >> .666 > > Or if you're allergic to regular expressions: > >>>> print "." + "0.666".split(".")[-1] > .666 >>>> print "." + "123.666".split(".")[-1] > .666 >>>>
> how about this solution: > def printDecimal(number): > if (number < 0): > print number - int(number) > else: > print int(number) - number Well, for one thing it doesn't work: >>> def printDecimal(number): ... if (number < 0): ... print number - int(number) ... else: ... print int(number) - number ... >>> printDecimal(0.666) -0.666 >>> printDecimal(-0.666) -0.666 >>> Secondly, it was top-posted. ;) -- Grant Edwards grante Yow! I appoint you at ambassador to Fantasy visi.com Island!!! -- http://mail.python.org/mailman/listinfo/python-list