Printing Columns

Terry Reedy tjreedy at udel.edu
Tue Apr 15 23:54:55 CEST 2003


"Peter Hansen" <peter at engcorp.com> wrote in message
news:3E9C5035.F52E63BB at engcorp.com...
> c = 3
> print '\n'.join([' '.join([myList[i] for i in range(s, len(myList),
c)])
>     for s in range(len(myList)/c+1)])
...
> Note: relies on current integer division, otherwise you need to add
an
> int() call in the last bit.

You can guarantee future truncating behavior by using // instead of /
now.

TJR






More information about the Python-list mailing list