"Python" built-in function zip

Source: Internet
Author: User

Receives two or more sequences and returns a list of tuples, and each tuple list contains the first element from each sequence

" ABC "  = [11,23,45]print(Zip (s,t)) for in Zip (s,t):     Print (pair) Print (List (Zip (s,t)))

D:\Python\Python35\python.exe d:/pycharmprojects/helloworld/src/ziptest.py
<zip Object at 0x00000201d6459648>
(' a ', 11)
(' B ', 23)
(' C ', 45)
[(' A ', one-to-one), (' B ', '), (' C ', 45)]

Process finished with exit code 0

The sequence length of the zip is different, then take the short one.

The number is not the same: t length is greater than s

s ="ABC"T= [11,23,45,77,88]Print(Zip (s,t)) forPairinchZip (s,t):Print(pair)Print(list (Zip (s,t))) D:\Python\Python35\python.exe D:/pycharmprojects/helloworld/src/ziptest.py<zip Object at 0x00000252de5b96c8>('a', 11)('b', 23)('C', 45)[('a', 11), ('b', 23), ('C', 45)]process finished with exit code 0

The number is not the same, s length is greater than t

s ="Abcer"T= [11,23,45]Print(Zip (s,t)) forPairinchZip (s,t):Print(pair)Print(list (Zip (s,t))) D:\Python\Python35\python.exe D:/pycharmprojects/helloworld/src/ziptest.py<zip Object at 0x0000024c7e2c9648>('a', 11)('b', 23)('C', 45)[('a', 11), ('b', 23), ('C', 45)]process finished with exit code 0

"Python" built-in function 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.