[Tutor] printing columns

Wesley J. Chun wesc@alpha.ece.ucsb.edu
Fri, 21 Jul 2000 01:29:49 -0700 (PDT)


    > From: "Richard Chamberlain" <richard_chamberlain@ntlworld.com>
    > Date: Fri, 21 Jul 2000 07:28:15 +0100
    > 
    > Hi Ben,
    > 
    > Why not use:
    > 
    > print "%6s %6s %6s" %(thelist[item1],thelist[item2],thelist[item3])

or, to enhance this story...

i = 1
while i < 650:
    print "%6s %6s %6s" % (thelist[i], thelist[i+1], thelist[i+2])
    i = i + 3

hope this helps!!

-wesley

    > 
    > Richard
    > ----- Original Message ----- 
    > From: Ben Beuchler <insyte@emt-p.org>
    > Sent: Thursday, July 20, 2000 11:29 PM
    > 
    > > I have a list of around 650 or so items.  I would like to be able to
    > > print them in columns, three across, like so:
    > > 
    > > item1 item2 item3
    > > item4 item5 item6
    > > item7 item8 item9
    > > 
    > > Any suggestions on a clean way to accomplish this?  The items will be of
    > > varying width, so just adding tabs won't reliably format them.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Bay Area Python Users' Group:  http://www.baypiggies.org

"Core Python Programming", Prentice Hall PTR, TBP Summer 2000
    http://www.phptr.com/ptrbooks/ptr_0130260363.html
    http://www.softpro.com/languages-python.html

wesley.j.chun :: wesc@alpha.ece.ucsb.edu
cyberweb.consulting :: silicon.valley, ca
http://www.roadkill.com/~wesc/cyberweb/