Zip lists in Python

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

    In Python 2.7 this might have worked fine:

    >>> a = b = c = range(20)
    >>> zip(a, b, c)
    

    But in Python 3.4 it should be (otherwise, the result will be something like ):

    >>> a = b = c = range(20)
    >>> list(zip(a, b, c))
    

提交回复
热议问题