List one of the data types built into the:P Ython is the list: list . A list is an ordered set of elements that can be added and removed at any time.
Constructing the list is very simple, [ ] just by enclosing all the elements of the list in the code above, which is a list object. In general, we assign a list to a variable so that it can be referenced by a variable to the list
Because Python is a dynamic language, the elements contained in the list are not required to be of the same data type, and we can completely include a variety of data in the list
Countdown : The second-to-last use-2 means that the countdown to the third use-3 means that the penultimate fourth uses-4 means:
list Additions and deletions : list append() method to append the new element to the end of the list
The method is to use the list insert() method, which accepts two parameters, the first parameter is the index number, the second parameter is the new element to be added
You can delete the last element by using the list pop() method, {pop () Delete to delete, cannot appear like pop (2), pop (3) This}
tuple:tuple is another ordered list, Chinese translates to "tuples". Tuple and list are very similar, however, once a tuple is created, it cannot be modified, the only difference between creating a tuple and creating a list is to ( ) replace the [ ],获取 tuple 元素的方式和 list 是一模一样的,我们可以正常使用 t[0],t[-1]等索引方式访问元素,
但是不能赋值成别的元素.()both can represent a tuple, and can be used as parentheses to indicate the priority of the operation, the result (1) is calculated by the Python interpreter results 1, resulting in we get not a tuple, but an integer 1. It is precisely because the tuple with the () definition of a single element is ambiguous, so Python specifies that the element tuple should have a comma ",", which avoids ambiguity
Python Beginner 1