Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Formatting Help
#3
(Jun-02-2019, 09:13 PM)perfringo Wrote: There is Format Specification Mini-Language.

If using 3.6 < Python then f-strings are way to go:

>>> food_charge = 11.99
>>> sales_tax = food_charge * 0.08
>>> print(f'The sales tax is ${sales_tax:.2f}')
The sales tax is $0.96

ur amazing, and it was in my notes the entire time and I completely looked over or did something weird with it. thank you!
Reply


Messages In This Thread
Formatting Help - by Expel - Jun-02-2019, 09:06 PM
RE: Formatting Help - by perfringo - Jun-02-2019, 09:16 PM
RE: Formatting Help - by Expel - Jun-02-2019, 09:17 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020