-1

How to add commas to digits in Python 3?

>>> income = 50000
>>> print("Your income tax is ${0}.".format(income))
Your income tax is $50000.

Just wondering how to print $50,000?

My question is not a duplicate If I change my second line to print("Your income tax is **${:,.2f}.".format(income)). I am getting $50,000.00, but I do not want any **extra zeros after the decimal point.

okKANMANI
  • 23
  • 2
  • 6

1 Answers1

2

Try this:

print("Your income tax is ${:,}".format(income))
DaNNuN
  • 328
  • 1
  • 3
  • 12