1. List
Python has 6 built-in types of sequences, but the most common are lists and tuples.
The operations that a sequence can perform include indexing, slicing, adding, multiplying, and checking members.
In addition, Python has built-in methods for determining the length of the sequence and determining the maximum and bottom elements.
A list is the most common type of Python data that can appear as a comma-separated value within a square bracket.
The data items of the list do not need to have the same type.
Create a list by enclosing separate data items separated by commas in square brackets. As follows
List = [' AAA ', ' bbbb ', ' CCCC ']
List1 = [1,2,3,4,5]
List2 = ["A", "B", "C", "D"]
As with the index of a string, the list index starts at 0. Lists can be intercepted, combined, and so on.
Accessing values in a list
Use the subscript index to access the values in the list, and you can also use square brackets to intercept the characters as follows:
The result of the above example output:
Update list
You can modify or update the list's data items, or you can use the Append () method to add the list items as follows:
The result of the above example output:
To delete a list element
The result of the above example output:
python list script operators
As shown below:
python list interception
Python common data Structures--list