Python Fundamentals: A list of common methods

Source: Internet
Author: User

Lst.append (x) | add element x to the list LST trailer

Lst.extend (L) | Add all elements from list L to the list LST tail

Lst.insert (index, x) | add element x at the list LST Development position index, and all elements behind that position move back one position

Lst.remove (x) | Deletes the first occurrence of the specified element in the list lst, with all elements after that element moving forward one

Lst.pop ([index]) | Delete and return the elements in the list LST table below index (Default-1)

Lst.clear () | Delete list lst all elements, but keep list objects

Lst.index (x) | Returns the number of occurrences of the specified element x in the list LST

Lst.reverse () | Reverse the list of all elements

Lst.sort (Key=none, reverse=flase) | Sorts the elements in the list LST, where key is used to specify the sort by, reverse determines whether ascending (False) or descending (True)

Lst.copy () | Returns a shallow copy of the list LST

Python Fundamentals: A list of common methods

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.