[Tutor] printing columns

alan.gauld@bt.com alan.gauld@bt.com
Mon, 24 Jul 2000 10:36:04 +0100


> Other people have suggested using:
>   print "%10s%10s%10s" % (item[i], item[i+1], item[i+2])
> 
> which will work well.  It will, however, be padded with spaces to the
> left, where we actually want padding on the right.  For example:
> 
> >>> print "%10s%10s%10s" % ('hello', 'world', 'test')
>      hello     world      test

So try using a minus sign:

>>> print "%-10s%-10s%-10s" % ('hello', 'world', 'test')
hello     world      test


Alan G.