zip list with different length

2007-04-04 Thread s99999999s2003
hi suppose i have 2 lists, a, b then have different number of elements, say len(a) = 5, len(b) = 3 a = range(5) b = range(3) zip(b,a) [(0, 0), (1, 1), (2, 2)] zip(a,b) [(0, 0), (1, 1), (2, 2)] I want the results to be [(0, 0), (1, 1), (2, 2) , (3) , (4) ] can it be done? thanks --

Re: zip list with different length

2007-04-04 Thread ginstrom
On Apr 4, 4:53 pm, [EMAIL PROTECTED] wrote: elements, say len(a) = 5, len(b) = 3 a = range(5) b = range(3) ... I want the results to be [(0, 0), (1, 1), (2, 2) , (3) , (4) ] can it be done? A bit cumbersome, but at least shows it's possible: def superZip( a, b ): common = min(

Re: zip list with different length

2007-04-04 Thread MC
Hi! Brutal, not exact answer, but: a = range(5) b = range(3) print zip(a+[None]*(len(b)-len(a)),b+[None]*(len(a)-len(b))) -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: zip list with different length

2007-04-04 Thread Peter Otten
[EMAIL PROTECTED] wrote: suppose i have 2 lists, a, b then have different number of elements, say len(a) = 5, len(b) = 3 a = range(5) b = range(3) zip(b,a) [(0, 0), (1, 1), (2, 2)] zip(a,b) [(0, 0), (1, 1), (2, 2)] I want the results to be [(0, 0), (1, 1), (2, 2) , (3) , (4) ] can it

Re: zip list with different length

2007-04-04 Thread Alexander Schmolck
[EMAIL PROTECTED] writes: C hi suppose i have 2 lists, a, b then have different number of elements, say len(a) = 5, len(b) = 3 a = range(5) b = range(3) zip(b,a) [(0, 0), (1, 1), (2, 2)] zip(a,b) [(0, 0), (1, 1), (2, 2)] I want the results to be [(0, 0), (1, 1), (2, 2) , (3) , (4)

Re: zip list with different length

2007-04-04 Thread Alexander Schmolck
MC [EMAIL PROTECTED] writes: Hi! Brutal, not exact answer, but: a = range(5) b = range(3) print zip(a+[None]*(len(b)-len(a)),b+[None]*(len(a)-len(b))) You reinvented map(None,a,b). 'as -- http://mail.python.org/mailman/listinfo/python-list