Python's Zip

Source: Internet
Author: User

#-*-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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.