Jan-25-2018, 07:12 AM
I'm trying to print out floats in currency format, but no matter what numbers I specify for rounding parameters, it only prints out one 0 after the decimal point:
#!/usr/bin/env python3 #FormattingStuff.py def listOfFloats(): floatsList = [20.0007, 20.00, 3.00, 5.780001] print("$" + str(round(floatsList[1], 2))) print("$" + str(round(floatsList[1], 3))) def main(): listOfFloats() main()The output is:
Error:======= RESTART: I:/Python/Python36-32/SamsPrograms/FormattingStuff.py =======
$20.0
$20.0
>>>
Why are they the same? I'm trying to output $20.00