Python: List

Source: Internet
Author: User

A list consists of a series of elements arranged by a particular element. Using [] in Python to represent a list

such as:: Bicycles = ["Trek", "Cannondale", "Redline", "specialized"]

To modify a list:

Bicycles.append ("Car") #在列表尾部添加新元素

Bicycles.insert (0, "car") #在列表任意位置插入元素, the example is the insertion element at index 0

Del Bicycles[1] #删除列表中任意位置的元素 (by index)

Bicycles.pop () #删除列表末尾的元素 (the element can be assigned to a variable), the POP function can be indexed, indicating the deletion of the element at the specified position

Bicycles.remove ("Trek") #根据值删除元素

Bicycles.sort () #对列表永久性排序

Bicycles.sorted () #对列表临时性排序

Bicycles.reverse () #反转列表元素

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