Python basic data structure--list

Source: Internet
Author: User

List:

1. an orderly set;

2. Index by the offset to read the data;

3. Support nesting;

4. Variable type;

List of actions:

1. Slices:

A = [1,2,3,4,5,6,7]

Forward Index

Reverse Index

Default Index

2. Add an action

1) + Generate a new list;

2) Extend accepts the parameter and adds each element of the parameter to the original list, modifying the list at the original address instead of creating a new list.

    

    3) Append: Add any object to the end of the list;

4) Insert: Inserts any object into the list, you can control the insertion position.

  

3. Modifications

Modifying the list itself requires only the direct assignment of the action.

4. Delete operation

1) Del: Deletes the element at the specified location by index.

  

2) Remove: Removes the first matching value from the specified value in the list. If it is not found, an exception is thrown.

3) Pop: Returns the last element and removes it from the list.

5. Member relations

1) in No in: Determines whether an element exists in the list. Returns a bool type in which the element returns true in the list, otherwise returns false

6. Sort/Reverse

1) Sort/reverse are directly modified on the original list, their return value is none.

Python basic data structure--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.