Python Series Tutorials (ii) read-only lists-tuples

Source: Internet
Author: User

Tuples, like lists, are also a sequence, and learning tuples requires two points: (1) tuples cannot be modified, so someone calls it "read-only List" (2) a comma in a tuple is important.

First, we create a tuple, which is as simple as separating some values with commas and automatically creating a tuple. Note that there is only one element when you need to add a comma.

>>> 1,2,3,4,5,6(1, 2, 3, 4, 5, 6)>>> 3, (3,)

Second, let's look at the conversion between different formats

>>> tuple ([1,2,3,4,5,6])   # list Conversion Narimoto Group (1, 2, 3, 4, 5, 6)>>> tuple ('  ABC')                # string Conversion narimoto group ('a' ) b ' ' C ')

Ganso Other basic operations can refer to the list, then we learn the meaning of Ganso?

(1) A tuple can be used as a key in a member of a map and a collection, but the list cannot be

(2) tuple as the return value of the built-in functions and methods

Python Series Tutorials (ii) read-only lists-tuples

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.