Printing lists in columns

cjt22 at bath.ac.uk cjt22 at bath.ac.uk
Tue Sep 4 16:52:30 CEST 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"
with a ^ pointing to fillvalue :S




More information about the Python-list mailing list