This is the content of the December plan, beginning in January 2018 ~
If there is any mistake, please ask for it ~
A list is the most commonly used Python data type and can appear as a comma-separated value within a square bracket.
The list of data items does not need to have the same type, which is already handy.
To access the available subscript and slice methods
1 list=['a','b','C', 2print(list[0])3print(List[1:4])
a['b'c', 1]
Update, change directly, add element at the end. Append
1 list=['a','b','c' , to]2print(list[0])3 list[0]=14 Print(list[0])
1 list=['a','b','C', 2 list.append (6)3print(list[5])
Del statement to delete the elements of the list
1 list=['a','b','C', 2del list[2]3print(List)
| Python Expressions |
Results |
Description |
| Len ([1, 2, 3]) |
3 |
Length |
| [1, 2, 3] + [4, 5, 6] |
[1, 2, 3, 4, 5, 6] |
Combination |
| [' hi! '] * 4 |
[' hi! ', ' hi! ', ' hi! ', ' hi! '] |
Repeat |
| 3 in [1, 2, 3] |
True |
Whether the element exists in the list |
| For x in [1, 2, 3]: print (x, end= "") |
1 2 3 |
Iteration |
In addition, its nesting and built-in functions are quite a lot of, later said
Python Data Type-List VI