Answers for "f string with format"

10

f string float format

>>> a = 10.1234
>>> f'{a:.2f}'
'10.12'
Posted by: Guest on July-21-2020
1

f string curency format

amt = 5.3568
print(f"I have ${amt:,.2f}.")
# Output: 
# I have $5.36.
Posted by: Guest on July-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language