Printing lists in columns

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Tue Sep 4 16:20:34 CEST 2007


cjt22 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



More information about the Python-list mailing list