Hey guys so I have an assignment due in my intro to Python class and my teacher noted (He hasn't explained it yet) that a certain part of the output has to be right-justified via the format() function.
So far I've learned a few things regarding format, such as these:
print(format(12345.6789,'.2f'))
print(format(12345.6789,',.2f'))
print('The number is ',format(12345.6789,'10,.3f'))
print(format(123456,'10,d'))
I understand these just fine, but here's what my professor wants in my program.
This is what needs right justification:
Amount paid for the stock: $ 350,000
Commission paid on the purchase:$ 27,000
Amount the stock sold for: $ 350,000
Commission paid on the sale: $ 30,00
Profit (or loss if negative): $ -57,000
These numbers are incorrect^ I forget the actual values, but you get the point.
Here's the code for those I already have.
#Output
print("\n\n")
print("Amount paid for the stock: $",format(stockPaid,',.2f'),sep='')
print("Commission paid on the purchase:$",format(commissionBuy,',.2f'),sep='')
print("Amount the stock sold for: $",format(stockSold,',.2f'),sep='')
print("Commission paid on the sale: $",format(commissionSell,',.2f'),sep='')
print("Profit (or loss if negative): $",format(profit,',.2f'),sep='')
So how do I get those values to print right justified while the rest of the string before each is left justified?
Thank you for your help you guys are awesome as always!