Python basic notes-sequence of data types (2)

Source: Internet
Author: User

First, List parsing

[I * 2 for i in [8,-2, 5]]--[16,-4, 10]

Ii.. Built-in functions

List.append (obj) adds an object to the list obj

List.count (obj) returns the number of times an object obj appears in the list

List.extend (SEQ) adds the contents of the sequence SEQ to the list

List.index (obj, I=0,j=len (list)) returns the K value of list[k] = = obj, and the range of K throws a ValueError exception in i<=k<j; otherwise.

List.insert (index, OBJ) inserts the object obj at the index position.

List.pop (index=-1) deletes and returns the object at the specified position, which is the last object by default

List.remove (obj) removes an object from the list obj

List.reverse () flip list in place

List.sort (Func=none,key=none,reverse=false) sorts the members in the list in the specified manner, if the Func and key parameters are specified, the individual elements are compared in the specified manner, and if the reverse flag is set to True, The list is ordered in reverse order.

Python basic notes-sequence of data types (2)

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.