The following is a reading note from Python tutorial:
I. Operations on the list
The difference between the remove,pop of 1.list and clear
List.remove (x): Removes an element with a list value from the list
List.pop ([i]): Removes the first element from the list, and if I is not specified, the last element is deleted.
List.clear (): Remove all elements from list
2. List-derived
We usually create a list from a sequence in the following way:
result = [] for in range: result.append (x)
The downside of using the above approach is that the variable I still exists after the loop, which we do not want to see, in order to avoid this waste of space, we use the following two ways:
for in range[map(Lambda i:i, range (10
The difference between 3.list and tuple
Both list and tuple are sequences of this type, but the list is mutable and the tuple is immutable. And the data types in the list are usually consistent, and the data types in the tuple are usually inconsistent.
Python data structure