Python Learning---data type---list

Source: Internet
Author: User

Python Learning

1. List []

1.1) A list is a data structure that handles a set of ordered items, that is, you can store a sequence of items in a list.

1.2) variable data type when listing

1.3) The list consists of a list of [] labels with multiple comma-separated numbers or strings

Example: list[1,2,3] list1['aaa', 123,'qwsx ']

Empty list list[]

Note: When you define a tuple with only one value, add a comma after it, and the list has only one value without adding any symbols

2. Operation of the list

2.1) Re-assignment of the list (in list1["Qaz", "Qwedc"])

list1[0]="aaa" view List1 's ID did not find a change.

2.2) Add a value to the list

List1.append ("123456") eg: adding data by Append method

2.3) Delete a value from the list:

List1.remove (list1[3]) or list1.remove["123456"] The latter removes the first occurrence of the value

Delete entire list: Del (list1[])

2.4) Helpful: Help (list.)

3. Quick start for objects and classes

3.1 Object = attribute + method

A list is a class, and the list1 we define ourselves is an object of the list. This object has append, Del,remove and other methods.

Python Learning---data type---list

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: 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.