Printing lists in columns

cjt22 at bath.ac.uk cjt22 at bath.ac.uk
Tue Sep 4 10:54:10 EDT 2007


On Sep 4, 3:20 pm, Bruno Desthuilliers <bruno.
42.desthuilli... at wtf.websiteburo.oops.com> wrote:
> cj... at bath.ac.uk a écrit :
> (snip)
>
> > Thanks guys
>
> > I have a list of lists such as
> >  a = ["1" , "2"]  b = ["4", "5", "6"]  c = ["7",8", "9"]
> > Stored in another list: d = [a,b,c]
>
> > I know this makes me sound very stupid but how would I specify
> > in the parameter the inner lists without having to write them all out
> > such as:
>
> > for row in izip_longest(d[0], d[1], d[2], fillvalue='*'):
> >     print ', '.join(row)
>
> > i.e. How could I do the following if I didn't know how many list of
> > lists I had.
>
> for row in izip_longest(*d, fillvalue='*'):
>      print ', '.join(row)
>
> HTH

I thought that, but when I tried it, I recieved a
"Syntax error: invalid syntax"
message with ^ pointing to the 'e' of fillvalue




More information about the Python-list mailing list