A sequence is the most basic data in Python. Each element in a sequence is assigned a sequence number, that is, the position of an element, also known as an index. Python contains 6 built-in sequences, in addition to the List and element groups, as well as strings, Unicode strings, buffer objects, and xrange objects (to be discussed later). Today, we will look at the list and element groups.
1. List and metadata differences
(1) The biggest difference between the two is whether the data can be modified, and the list can be modified. It allows us to add or delete any element, which is suitable for situations where elements change frequently, however, tuples cannot be modified. This is generally related to the internal operation of Python. For example, if you use tuples as Dictionary keys, the list cannot be used because keys cannot be modified.
(2) The second difference between the two is that the representation method is different. Because the Python language does not specify the Data Type of the variable during input, the type of the variable is dynamically recognized by the compiler and runtime, if the type cannot be operated, an exception is thrown. The list uses [] to include all elements, and some people may say that () is used for tuples. That's right, but in addition to this method, you can also leave () unspecified (), as long as the elements are separated by commas, for example
>>> Type (member) <class 'tuple'>
Or >>> member = 6, >>> type (member) <class 'tuple'>
2. General sequence operations
List and metadata