Added elements of the list
L1 = [10, 20, 30]
L1.append (40) # appends an element with a value of 40 to the end
L1.extend ([50, 60]) # Appends a series of elements to the end, extend + iterates over an object
L1.insert (Len (L1), 70) # Inserts an element in the set subscript position, before the specified subscript
List of deleted elements
m = L1.pop () # Deletes an element without an input parameter, which defaults to deleting the last one and returning the deleted element value
Print (m) # 70
L1.pop (0) # Delete an element with the subscript 0 position
L1.remove (10) # remove elements with an element value of 10
L1.remover (1000) # If this value is not true, an error will be ValueError:list.remove (x): X not in List
L1.clear () # Empty list
L1 = [10, 20, 30]
List reversal
L1.reverse ()
L1 = [90, 30, 70, 20, 10, 60]
List sort
The list name. Sort (key,reverse) key indicates which function to sort by, whether the reverse is large or small
L1.sort (reverse = true) # from big to small
L1.sort (reverse = False) # Small to large
L1.sort () # No input parameters, default from small to large
Built-in function sorted (key,reverse)
L1 = sorted (L1, Reverse=true)
14 Basics of Python programming