{:,} print number with commas every 1,000

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
blakebr
 
Posts: 957
Joined: Tue Apr 17, 2012 6:23 pm

{:,} print number with commas every 1,000

Post by blakebr »

Hello,

How do I print 10,000,000 with the commas in CircuitPython? My searches points me to Pyhon using {:,} in the .format line, but CircuitPython doesn't support that.

Bruce

User avatar
adafruit_support_carter
 
Posts: 29164
Joined: Tue Nov 29, 2016 2:45 pm

Re: {:,} print number with commas every 1,000

Post by adafruit_support_carter »

What board and version of CircuitPython are you using?

Code: Select all

Adafruit CircuitPython 7.3.3 on 2022-08-29; Adafruit QT Py RP2040 with rp2040
>>> "{:,}".format(10000000)
'10,000,000'
>>> 

User avatar
blakebr
 
Posts: 957
Joined: Tue Apr 17, 2012 6:23 pm

Re: {:,} print number with commas every 1,000

Post by blakebr »

Carter,

It works. I thought I tried that. I must have fat-fingered something.

Thank you,
Bruce

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”