Home

On 2007-09-04, Chris.Tidy@jet.uk <Chris.Tidy@jet.uk> wrote:
> Thanks guys. Changing to how Python does things has a lot of geting
> used to!

That's part of the fun :-)

> Do any of you have any ideas on the best way to do the following
> problem:
>
> 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



Good luck,
Albert

previous
next

Re: Exposing private member functions to extern C function
How many lines of code per day should a good programmer produce?
Re: correction
Re: C++ OO design question
Re: Problem with subprocess.Popen()
Akogo
Niechciane i Zapomniane
Pajacyk
Dzieci Niczyje
Fundacja Sloneczko