"A.T.Hofkamp" <[EMAIL PROTECTED]> wrote:

>> Each loop I perform, I get a new list of Strings.
>> I then want to print these lists as columns adjacent to each other
>> starting with the first
>> created list in the first column and last created list in the final
>> column.
> 
> Use zip:
> 
>>>> x = ['1', '2']
>>>> y = ['3', '4']
>>>> for row in zip(x,y):
> ...   print ', '.join(row)
> ...
> 1, 3
> 2, 4
> 
> 
> zip() constructs a list of rows, like
> 
> [('1', '3'), ('2', '4')]
> 
> which is then quite easy to print

But watch out if the lists aren't all the same length: zip won't pad out 
any sequences, so it may not be exactly what is wanted here:

>>> x = ['1', '2', '3']
>>> y = ['4', '5']
>>> for row in zip(x,y):
        print ', '.join(row)

        
1, 4
2, 5
>>> 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to