//Cash=6600.0
AR=6200.0
tne=25000.0
TotalAssets=Cash+AR+tne
np=5000.0
ap=25000.0
TL=np+ap
Capitalstock=7000.0
re=800.0
totalEquity=Capitalstock+re
total=TL+totalEquity
print("{0:<21s}""${1:>20,.0f}""{2:<2}""{3:<21s}""${4:>21,.0f}".format("Total",total,"","Total",total))
where the output value is
It comes out like this.
I'd like to put a total of 21 spaces and a total of 37,800 spaces and put a dollar sign right in front of the number for $37,800, what should I do?
python
In the front of the output statement "${1:>20,.0f}"
":>" is a grammar for right alignment.
I think the dollar and the number are 20 spaces apart.
Exclude the grammar that aligns in that part
All you need to do is write "${1:0.1f}"
.
© 2024 OneMinuteCode. All rights reserved.