Yesterday rest day, to make up today. List learning

First, a list of

1, the list of definitions

Listing a series arrangement of elements in a certain order. In python we use [] represents a list of the elements which are separated by commas.

 

 

 

 2, the access list elements

List is an ordered collection of elements only need to access the list of list element position or index can tell python.

(1) index from 0

 (2) a negative index starting at -1, the number of backwards

 

 

 

3, add modify delete list elements within

Adding elements within (1) List

To add an element, use the list in the end of the list append ()

Insert elements in a list, use the list method insert ()

 

 

 

 (2) modify the element

Direct changes in the list of index call

 

 

 

 (3) remove elements

Use del to delete an element of the list

 

 

 

 Use pop to delete an element of the list, delete and extract elements

 

 

 

 According to a list of elements with the value delete remove

 

 

 

Guess you like

Origin www.cnblogs.com/xiaobai-yang/p/11614196.html