Mata Uang Format Python
amt = 5.3568
print(f"I have ${amt:,.2f}.")
# Output:
# I have $5.36.
Trained Tuna
amt = 5.3568
print(f"I have ${amt:,.2f}.")
# Output:
# I have $5.36.
formatted_float = "${:,.2f}".format(1500.2)
def as_currency(amount):
if amount >= 0:
return '${:,.2f}'.format(amount)
else:
return '-${:,.2f}'.format(-amount)