[Tutor] Looking for a Pythonic way to pass variable number of lists to zip()

Kent Johnson kent37 at tds.net
Tue Mar 22 13:47:27 CET 2005


Shidai Liu wrote:
> On Mon, 21 Mar 2005 22:51:31 -0800, Sean Perry <shaleh at speakeasy.net> wrote:
>>arg_list = []
>># fill up arg_list
>>zipped = zip(*arg_list)
>>
> 
> I met a similar question.
> what if one has L = [[1,2],[3,4]], K = [100, 200]

What do you want to do with these lists?

> How to 'zip' a List like [[1,2,100], [3,4,200]]?

  >>> zip(*[[1,2,100], [3,4,200]])
[(1, 3), (2, 4), (100, 200)]

If that's not what you mean, please give an example of the input *and results* you want.

Kent



More information about the Tutor mailing list