[Tutor] Displaying data in columns

Alan Gauld alan.gauld at btinternet.com
Mon May 7 22:02:24 CEST 2012


On 07/05/12 14:43, Thomas C. Hicks wrote:

> I would like to display some of the items in the tuples in columnar
> format with each column lining up on the left side (below should be
> three neat columns with location, training type, number trained and
> date):

You need to read up on string formatting. That allows you to specify the 
length of fields, whether they are left or right justified, any leading 
pad characters etc. This is not in a module but is a standard feature of 
Python.


For anything more exotic you should look to a formatting language
like HTML.


Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list