python--List

Source: Internet
Author: User

List

1list : array of hormones hit

Array ( scores) is a structure that can store only the same data type ;

array : scores[43] = [12.0, "Hello"]

tuples ( tuple can store multiple data types, but cannot change the elements;

definition:: A list of elements that can be any type , including numeric types , lists , strings, etc. are available.

List ( List ) can store multiple data types, but can change the elements in them;

definition: A list of elements that can be any type , including numeric types , lists , string, and so on, can be empty.

2. Analysis List features: (vs. tuples)

? List Index

forward index: is calculated starting from 0 , such as l[0] Reading is the list of 1 an element ;

Reverse index:l[-1] reads the bottom 1 elements of a list

Take out the last element of the list, the last element is the list , then the third element of the list

? list slices

Remove the first element of a list

Display the elements in reverse order

? duplicate list, connect

It is not recommended to use this method to recommend the following

? member Operators

3, List of additions and deletions to check

? Increase

IP White list

ALLOW_IP = ["172.25.254.1", "172.25.254.3", "172.25.254.26"]

Append element to the end of the list

add element to the specified position in the list

# Iterable represents an iterative ;

# There are currently iterative objects for learning : str, list, tuple

Add multiple elements to the end of the list

? Change

re-assign a value to a list index value through the index of the list

? Check

Count the number of occurrences of an element in a list

Find the index value of a value in the list

? Delete

Remove the first value value that is encountered in a list

Remove the I index value from a list

Remove index values other than the first element

deletes the value corresponding to the specified index , which is the last element by default

? other sort and reversal

sort , if that's all numbers , Sort by number size

is the letter , according to the ASCII code to sort ;

How do I view the corresponding ASCII code ? Ord (' A ')

Reverse

method 1:

Method:2

4. List build stack and queue data structure

Stack

? stack is advanced after out (Lifo-first in);

? It's like putting a book in a box . ;

? The code is implemented as follows : ( This is too much trouble in real-world applications and will be implemented in the future )

Queue

? The queue is first in, Out (FIFO);

? like to go to a restaurant to buy a meal in line .

5. List built-in methods

? cmp

? min, Max

? zip

? Enumerate


python--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.