Python tuple (tuple)

Source: Internet
Author: User

Tuple tuples

Tuples cannot be changed once they are created

Representation method:

name1= ("Luo", "gu", "Hu")

Within a tuple, it can be a string, a number, or a mixed type

For a tuple operation, the following functions are available:

#1, CMP (name1,name2): Elements used to compare two tuples

#2, Len (name1): Number of tuple elements

#3, Max (NAME1): Returns the maximum value in the tuple

#4, Min (name1): Returns the minimum value in the tuple

#5, tuple (list): Converts a tuple to a list, or a list to a tuple

Description: The values in the tuple are immutable

Second, the list operation contains the following methods:

#1, del name1 Delete tuples

#2, List.count (obj): Counts the number of occurrences of an element in a tuple

#3, Tuple.index (obj): Find the index position of the first occurrence of a value from a tuple (subscript)

#4, Tuple.reverse (): an element in a reversed tuple

#5, Tuple.sort ([]): Sorting primitive tuples

Python tuple (tuple)

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.