################################################################## ################################################################## ### ### ### zip ### ### ################################################################## ################################################################## # zip takes a variable number of arguments, each of # must be a Python sequence. # Returns a list of n-tuples, where n = the number of arguments of # zip. The i-th n-tuple is made up of the i-th element # of each of the arguments of zip. >>> zip([1,2,3],['a','b','c']) [(1, 'a'), (2, 'b'), (3, 'c')] # 2 arguments: Returns a list of pairs >>> zip([1,2,3],['a','b','c'],['z','y','x'],[3,2,1]) [(1, 'a', 'z', 3), (2, 'b', 'y', 2), (3, 'c', 'x', 1)] # 4 arguments >>> zip(['a','b']) [('a',), ('b',)] # 1 argument ## Returns a list of 1-tuples >>> zip([1,2,3],'abc') [(1, 'a'), (2, 'b'), (3, 'c')] >>> zip('xyz',(1,2,3)) [('x', 1), ('y', 2), ('z', 3)] ## Can mix different types of Python sequences. All args will be ## 'taken apart'. Whatever types of sequence is input, always returns a LIST ## pairs ##### NOTE: ################################################### ### Each argument of zip must be a Python SEQUENCE, the kind ### of X for which it makes sense to find X[i]: the i-th element of X #################################################################