Align numbers at decimal point

Michael Geary Mike at Geary.com
Wed Sep 15 14:49:57 EDT 2004


Enno Middelberg wrote:
> I want to print out columns of numbers which are aligned at
> the decimal point, eg:
>
> 123.45
>   3.0
>  65.765486

Those decimal points are not aligned on my display.

You can probably guess why: I'm using a proportional font, and spaces are 
not as wide as digits.

So, in addition to the algorithmic tips you've gotten, you need to be sure 
you're printing in a monospaced font such as Courier.

If you print in a proportional font, you need to use other means to align 
the decimal points instead of padding with spaces.

-Mike





More information about the Python-list mailing list