I have in my database the values a, b, and c, as example. Now i need to format theses values to a1, b1 and c1.
a) 2000000000
a1) 20,000,000.00
b) 300000
b1) 3,000.00
c) 30000
c1) 300.00
I tried this:
'{:20,.2f}'.format(30000) # 30,000.00 and i need 300.00
'{:20,.2f}'.format(300000) # 300,000.00 and i need 3,000.00
...
So, what i am trying is not working as expected. Anyone has an idea how can achieve the format that i am looking for?
You're passing in integers but you want to display floating point numbers.
You could fix this by passing floats or by dividing by the number of decimal points
'{:20,.2f}'.format(30000/100.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With