#-*-coding:utf-8-*-#python#Xiaodeng#Python's Zip#http://python.jobbole.com/82590/#1) Zip syntax format:" "Zip (...) Zip (seq1 [, SEQ2 [...]]), [(Seq1[0], seq2[0] ...), (...) Return a list of tuples, where each tuple contains the i-th element from each of the argument sequences. The returned list is truncated in length to the length of the shortest argument sequence." "#SEQ1,SEQ2: Sequence#Case#each time the loop is taken, an element is removed from the sequence from left to right, merged into a tuple, and then assembled into a list. list1=[1,2,3]list2=['Xiaodeng','Xiaochen','Xiaoni']PrintZip (list1,list2)#[(1, ' Xiaodeng '), (2, ' Xiaochen '), (3, ' Xiaoni ')]#support for more than 2 list assembly. Ta = [A.]TB= [9,8,7]TC= ['a','b','C']PrintZip (TA,TB,TC)#[(1, 9, ' a '), (2, 8, ' B '), (3, 7, ' C ')]#list length is not the case, according to the general thinking of people present. list1=[1,2,3,4]list2=['Xiaodeng','Xiaochen','Xiaoni']PrintZip (list1,list2)#[(1, ' Xiaodeng '), (2, ' Xiaochen '), (3, ' Xiaoni ')]list1=[1,2,3]list2=['Xiaodeng','Xiaochen']PrintZip (list1,list2)#[(1, ' Xiaodeng '), (2, ' Xiaochen ')]
Python's Zip