[Tutor] Field Width
Jenny Allar
jennyallar at gmail.com
Thu Sep 19 14:09:55 CEST 2013
Thanks, Dave.
Your statement "it does nothing to guess what else you put on the line" was
like a light bulb that went off in my head. I think I was relating the
field width to a left, center, or right justification, and that's not the
case at all.
Well now I feel silly!
Thanks,
Jenny
On Thu, Sep 19, 2013 at 5:24 AM, Dave Angel <davea at davea.name> wrote:
> On 18/9/2013 12:50, Jenny Allar wrote:
>
> > I'm only a few days in to learning Python, so please bear with me.
> >
> > I need to line up the decimals on the printed information but I cannot
> get
> > the text to look uniform at all.
> >
> >
> > Here is my code:
> >
>
> <snip>
>
> >
> > # Print infomation
> > print("The cost of the carpet is $", format(subtotal,'9,.2f'))
> > print("The flat fee is $", format(fee,'9,.2f'))
> > print("The tax is $", format(tax_rate,'9,.2f'))
> > print("The total due is $", format(total_due,'9,.2f'))
> >
>
> Have you tried lining it up in the source?
>
> # Print infomation
> print("The cost of the carpet is $", format(subtotal,'9,.2f'))
> print("The flat fee is $", format(fee,'9,.2f'))
> print("The tax is $", format(tax_rate,'9,.2f'))
> print("The total due is $", format(total_due,'9,.2f'))
>
> The format() method can handle variability in the floating point number,
> but it does nothing to guess what else you put on the line.
>
> Does that help?
>
>
> --
> DaveA
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130919/f2a11255/attachment-0001.html>
More information about the Tutor
mailing list