List
The 1 list consists of a series of elements arranged in a particular order. In Python, the square brackets [] are used to delimit the elements in a comma.
2 Access list element------Index (ordered collection)
Output Result:
3 modifying, adding and deleting elements
Modify:
Output Result:
Add to:
Output Result:
Append (the element is added by default at the end of the list), and there is an arbitrary insertion element insert
Output Result:
Delete (there are three types)
A; Know list index Del
Output Result:
B: Do not know where the element is in the list, and know the element value to remove:
Output Result:
C; Remove the end of list element pop
Output Result:
Pop there's another way of knowing the list index
Output Result:
Can be summed up in four words: increase, delete, change, plug
4 List of Actions
Traverse the entire list:
Output Result:
List slices (Gu Tou regardless of tail):
Output Result:
Slices can also traverse:
Output Result:
5 List Length:
Output Result:
6 Use the method sort () to sort the list in a permanent order:
Output Result:
Use the method sort () to sort the list temporarily
Output Result:
Reverse the Print List:
Output Result:
Index
Output Result:
Python List Dictionary tuple