Common actions for Python lists

Source: Internet
Author: User

Describes how to work with lists, including create, access, update, delete, other actions, and more

Create a list: just enclose the comma-delimited data items in square brackets.

Accessing the values in the table

Value exceeds index error, slice exceeds index no error

Update list: The data in the list can be modified or updated, or you can use the Append () method to add list items

Use the Append () function to add

Delete list Element del ()

List script operator Len (), ' + '

Iteration

Whether to include judgment

Slice reverse output

List operation function Len () CMP (List1, LIST2) max (list) min list (seq): Convert tuples to lists

Count (object): Counts the number of occurrences of an element in a list

Index (object): Find the index position of the first occurrence of a value from the list

Remove (object) Removes the first occurrence of a value in the list

Insert (Index, object) Inserts an object into a position in the list

Pop (index): Removes an element from a location in the table, without writing the default last

Extend (SEQ): Appends multiple values of another sequence at the end of a class table

Reverse (): Reverse List of elements

Sort ([func]): Sort the original list

Copy () replication creates a new memory space

Clear (): Empty list

Common actions for Python lists

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.