-2

I have this code finished and it runs fine, i just cannot figure out how to add commas into each dollar value.]

Here are pics of the code: Pic 1 Pic 2

Any help would be great, Thanks.

1 Answers1

1

You'll need to format the float numbers yourself.

Or use babel.numbers.format_currency, from the Babel library. See: http://babel.pocoo.org/en/latest/api/numbers.html

Example:

>>> format_currency(1099.98, 'USD', locale='en_US')
u'$1,099.98'

You can also use this format:

print ("${:,.2f}".format(1234.56))
# -> $1,234.56
Laurent LAPORTE
  • 21,958
  • 6
  • 58
  • 103