PyProg PyProg wrote:
> Hello,
>
> I have a little problem, I have two lists:
>
a=[1, 2, 3, 4, 5, 6]
b=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
>
> ... and I want to obtain:
>
[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6), ('g',
> 1), ('h', 2), ('i', 3), ('
Assuming that len(b) > len(a):
>>> zip(itertools.cycle(a), b)
[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f'), (1, 'g'), (2,
'h'), (3, 'i'), (4, 'j')]
Andreas
Am Dienstag, den 18.03.2008, 16:23 +0100 schrieb PyProg PyProg:
> Hello,
>
> I have a little problem, I have two lists:
>
Hello,
I have a little problem, I have two lists:
>>> a=[1, 2, 3, 4, 5, 6]
>>> b=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
... and I want to obtain:
>>> [('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6), ('g',
1), ('h', 2), ('i', 3), ('j', 4)]
I want to obtain that with a co