Lists List
Features: ordered, support for different types of elements in a list, mutable (using the Sort method to sort, affects the list itself rather than creating a new list-this is different from the string, so the string is immutable)
The list is also an object in Python, so he also has properties and methods help (list)
List operation:
1, orderly characteristics, you can use for. In.. Looping through lists
2, Basic: Increase, delete del, change, check
3. Intercept list: [2][-2] The penultimate [1:] Start intercept from the second element [2:4] (slice)
4. Script operator: + connection, * repeat
First, the function
1, CMP (LIST1,LIST2) #比较2个列表中的元素? Http://www.runoob.com/python/att-list-cmp.html
2, Len ()
3, Max () method returns the maximum value in a list element
4, Min () method returns the minimum value in a list element
5. The list () method is used to convert tuples to lists
Second, the method
1, append (), no return value, add new object at the tail, modify the original list directly
2. The count () method is used to count the number of occurrences of an element in a list
3, Extend (), no return value, add a new sequence at the tail, directly modify the original list
4. Index () find the index position of the first occurrence of a value from the list
5, insert (index, obj) No return value, directly inserted
6, Pop (index) removes an element from the list (the last element by default), and returns the value of the element
7. Remove () Removes the first occurrence of a value in the list
8. Reverse () flips the elements in the list
9, Sort (func ()) Order, can add function to specify Sort method
Python list operation