Zip lists in Python

前端 未结 10 2081
无人及你
无人及你 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:48

    For the completeness's sake.

    When zipped lists' lengths are not equal. The result list's length will become the shortest one without any error occurred

    >>> a = [1]
    >>> b = ["2", 3]
    >>> zip(a,b)
    [(1, '2')]
    

提交回复
热议问题