This is the P2PU Archive. If you want the current site, go to www.p2pu.org!

Learn Python the Hard Way

My recent threads

You haven't posted any discussions yet.

Recently updated threads

Simple function with %f placeholder.

Go back to: General discussion

# This simple function will format a number into a dollar value with 2 decimals.

def convertDollar(number):
       return "$.2%f"%number

>>> convertDollar(100)
$100.00

>>>convertDollar(501.1555)
$501.16