for x,y in word1, word2 ?

Jon Clements joncle at googlemail.com
Mon Aug 11 08:55:42 CEST 2008


On Aug 11, 5:40 am, Mensanator <mensana... at aol.com> wrote:
> On Aug 10, 11:18 pm, ssecorp <circularf... at gmail.com> wrote:
>
> > Is there a syntax for looping through 2 iterables at the same time?
>
> > for x in y:
> > for a in b:
>
> > is not what I want.
>
> > I want:
> > for x in y and for a in b:
>
> Something like this?
>
> >>> a = ['a','b','c']
> >>> b = [1,2,3]
> >>> zip(a,b)
>
> [('a', 1), ('b', 2), ('c', 3)]

I would have thought the difflib library and SequenceMatcher would do
(more than) what you're after.

Just an idea anyway,

Jon.




More information about the Python-list mailing list