Iteration over two sequences
It's me
itsme at yahoo.com
Wed Jan 12 12:50:36 EST 2005
I tried this and I got:
[(1, 'a'), (2, 'b'), (3, 'c')]
But if I change:
a=[1,2]
I got:
[(1, 'c')]
Why is that? I thought I should be getting:
[(1, 'a'),(2,'b')]
?????
"Diez B. Roggisch" <deetsNOSPAM at web.de> wrote in message
news:34kvs0F4bqiviU1 at individual.net...
> zip or izip is your friend:
>
> import itertools
>
> a = [1,2,3]
> b = ['a', 'b', 'c']
>
> for a,b in itertools.izip(a, b):
> print a, b
>
> --
> Regards,
>
> Diez B. Roggisch
More information about the Python-list
mailing list