. 1 # List [starting index: Index termination (not included): step interval] 2 List1 [. 5:. 8] # step is omitted, the default is 1 . 3 . 4 . 5 # edit list element 6 # list is a variable data type, it is possible to modify the content . 7 List1 = [0,1,2,3,4 ] . 8 listt1 [2] = ' Python '
Some methods list:
list.append (obj) add new objects in the end of the list
1 list1 = [0,1] 2 list1.append('Alice']
list.count (obj) count the number of an element that appears in the list
list.extend (seq) a plurality of additional one-time values at the end of the other sequence list (list with a new original extended list)
list.index (obj) to find a value that matches the first index location from the list
list.insert (index, obj) into the list object
list.pop (obj = list [-1]) removes an element in the list (default to the last element). And returns the value of the element
list.remove (obj) Removes the first occurrence of a value in the list
list.reverse () direction of elements in the list
list.sort ([func]) to sort the list of the original
-------------------------------------------------- ------- shame dividing line --------------------------------------- ---------------------------
List of Formula
[Expression for i in the sequence]
1 [i**2 for i in range(1,11)]