Python Collection--a tuple that is directly connected with a comma, not a list

Source: Internet
Author: User

1234554321' hello! ' T[0]12345t(12345, 54321, ' hello! ')        

Tuples: Tuples consist of several values separated by commas


Collection: Set (). The elements in the collection are not in order and are not duplicated. The basic purpose of a collection is to have members test and eliminate duplicate entries. The collection object also supports mathematical operations such as set, intersection, difference, and symmetry.
Curly braces or set () functions can be used to create collections. Note: To create an empty collection you must use set ()and cannot use {}; The latter will create an empty dictionary.
A=Set(' Abracadabra ')>>>B=Set(' Alacazam ')>>>a # unique letters in Aset ([' A ', ' R ', ' B ', ' C ', ' d '])  >>> a -b # letters in A and not in Bset ([' R ', ' d ', ' B ']) >>> a | b # letters in either a or Bset ([' A ', ' C ', ' R ', ' d ', ' B ', ' m ', ' Z ', ' l ']) >>> a & b # letters in Both A and Bset ([' A ', ' C ']) >>> a ^ b # letters in A or B and not bothset ([' R ', ' d ', ' B ', ' m ', ' Z ', ' l '])                   



Similar to the list deduction type,

The collection also supports the derivation formula:

>>>
{' abc '}aset ([' R ', ' d '])   




Python Collection--a tuple that is directly connected with a comma, not a list

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.