Python Learning Note Two _ list

Source: Internet
Author: User

Python does not need to declare type information because the Python variable identifier does not have a type.

When a list is created in Python, the interpreter creates an array-like data structure class in memory to store the information, and the data items are stacked up from bottom up (forming a stack). The index starts at 0.

Use the bracket notation to access the list data, such as movies[1].

List using:

cast=["Cleese", "Palin", "Jones", "", "Idle"]

Print (CAST) # #打印整个列表

Print (len (cast))

Print (Cast[0])

Add a data item at the end of the list, using the Append () method, such as Cast.append ("Gilliam")

Delete data from the end of the list, using the Pop () method, such as Cast.pop ()

Add a collection of data items at the end of the list, using the Extend () method, such as Cast.extend (["AA", "BB"])

Locate and delete a specific data item in the list, using the Remove () method, such as Cast.remove ("BB")

Add a data item in front of a specific location, using the Insert () method, such as Cast.insert (0, "CC")

Python Learning Note Two _ 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.