[Zero-basic learning Python note 012] an array of hormones 3 illustration

Source: Internet
Author: User

[Zero-basic learning Python note 012] an array of hormones 3 illustration
List Operators

 

Comparison operator logical operator join operator repeat operator member Operator

 

+ Indicates two connections; * Indicates replication.

The types of "+" in list must be consistent.

 

Example:

 

Note:: You can use append () or insert () to add elements ()

 

In and not

The method for viewing an element that is not in the list: in and not in; the method for viewing the list in the list is similar to the method for accessing elements in a two-dimensional array in C language.

 

Example:

 

 

List of friends

Count () is used to count

Index () is used to find the location. It can be a parameter or three parameters. The first parameter indicates the element to be searched, and the second parameter indicates the start position, the third parameter indicates the termination position.

Reverse () is used for elements in the inverted list.

Sort () is used to sort list elements. By default, it is sorted from small to large. To be large to small, use sort () and reverse (). In this case, we can use sort () to re-write the power. At this time, it has three parameters, the first two are default, and the third is reverse = False. We can change it to reverse = True, that is, sort (reverse = True)

 

Example:

 

The difference between copying part lists and directly using "=" is that Python variables are like a label, just a name, and where they are stored.

 

Example:

 

The above examples are illustrated;

 

 

Related Article

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.