Zip lists in Python

前端 未结 10 2214
无人及你
无人及你 2020-11-22 02:09

I am trying to learn how to \"zip\" lists. To this end, I have a program, where at a particular point, I do the following:

x1, x2, x3 = stuff.calculations(wi         


        
10条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 02:34

    zip creates a new list, filled with tuples containing elements from the iterable arguments:

    >>> zip ([1,2],[3,4])
    [(1,3), (2,4)]
    

    I expect what you try to so is create a tuple where each element is a list.

提交回复
热议问题