looping through a list of lists.
rob at cs.brown.edu
Wed Oct 8 19:42:00 CEST 2003
Oh. That's pretty cool actually.
On Wednesday, October 8, 2003, at 01:15 PM, Peter Otten wrote:
> Rob Hunter wrote:
>> The responder to this post has a cool way of doing it, but it won't
>> work (I believe) if you have an arbitrary number of sublists. Can you
>> clarify the problem? Do you have an arbitrary number of sublists? Or
>> is it always 3?
> I you are referring to the zip trick posted by
> SBrunning at trisystems.co.uk,
> it *does work for an arbitrary number of sublists, but not for
> arbitrary-length sublists:
>>>> for loc in zip(*"alpha beta gamma delta".split()):
> ... print loc
> ('a', 'b', 'g', 'd')
> ('l', 'e', 'a', 'e')
> ('p', 't', 'm', 'l')
> ('h', 'a', 'm', 't')
More information about the Python-list