Printing Columns

David Lewis DavidMLewis.NO at
Tue Apr 15 22:41:42 CEST 2003

In article <mailman.1050426466.11198.python-list at>, Lindstrom
Greg - glinds <Greg.Lindstrom at> wrote:

> Hello-
> I have been working on a little project and have come across an interesting
> (to me) problem.  I have a list of stuff that I would like to print to
> stdout in columns.  Now, it's no problem to print it out as follows:
> myList = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
>  A  B  C
>  D  E  F
>  G  H
> but I would like
>  A  D  G
>  B  E  H
>  C  F
This should give you a start:

>>> x = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
>>> x[0: :3]
['a', 'd', 'g']
>>> x[1: :3]
['b', 'e', 'h']
>>> x[2: :3]
['c', 'f']


More information about the Python-list mailing list