looping through a list of lists.
Rob Hunter
rob at cs.brown.edu
Wed Oct 8 13:42:00 EDT 2003
Oh. That's pretty cool actually.
Rob
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')
>>>>
>
> Peter
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list