I am working on a practice exercise using Python 3.7.2. The program takes the input, total sales in this problem, and calculates and display the total profit.
Is there a way to pre-format the input float so looks more like currency, with a dollar sign, commas separating the thousands, and two digits at the end for cents?
Currently, the program works fine as long as I enter any given integer.
The output appears just like it should, but the input just appears as a large row of numbers.
The input should appear as $23,987,456.00.
def main():
display_message()
# Get sales
total_sales = float(input("Enter the total sales: "))
# Calculate annual profit
total_profit = total_sales * annual_profit
display_results(total_profit)
def display_message():
print("")
print("This program determines the annual profit from the total sales, and")
print("displays the projected amount.")
print("")
def display_results(total_profit):
print("")
print('The total profit is: $', format(total_profit, '6,.2f'))
# Define global constants and call main
annual_profit = float(0.23)
main()