Built-in operation of Python list

Lists are sequence types, so the operators and functions of the 12 sequence types in the table can be applied to the list type. Since the list is variable, Table 6.4 shows the 14 additional commonly used functions or methods of the list type.

Insert picture description here

Like a tuple, a list is an ordered sequence, which includes 0 or more object references, and supports operations and functions common to the sequences in Table 5-6. But unlike tuples and strings, the length and content of the list are variable, and you can freely add, delete, or replace data items in the list. The list has no length limit, and the element types can be different. Therefore, the list is widely used.
There are several common methods for creating lists: they can be generated by explicit data assignment, separated by commas; you can use [] to generate an empty list, and then use related methods (such as append (), extend (), insert () Etc.) Add elements to the list; you can use the list () function to convert a tuple or string into a list.
Since the list is variable, in addition to the common functions and operations in Table 1, Table 3 lists some common methods and functions of list types.
Insert picture description here
Python provides a series of built-in operations for list types, including append (), insert (), pop (), remove () and other functions, which can easily handle the above list element changes.

Published 19 original articles · praised 7 · visits 574

Guess you like

Origin blog.csdn.net/liu201812/article/details/104740307