Sequence sequence
A sequence is a set of sequential elements
There are two types of sequences: tuple (fixed value table; also translated as tuple) and List (table)
>>>S1 = (2, 1.3, ' love ', 5.6, 9,, False) # S1 is a tuple
>>>S2 = [True, 5, ' smile '] # s2 is a list
The main difference between a tuple and a list is that once established,each element of a tuple cannot be changed, and the elements of the list can be changed again.
References to elements
The subscript of the sequence element starts with 0
Other reference methods
Range Reference: Basic style [lower limit: Upper limit: Step length]
As can be seen from the above, the upper limit is not included in the range reference when the upper limit is indicated .
Trailing element reference
>>>print S1[-1] # The last element of a sequence
>>>print S1[-3] # third element of sequence countdown
Similarly, if s1[0:-1], then the last element will not be referenced (again, excluding the upper bound element itself)
string is a tuple
strings are a special element, so you can perform related operations on tuples.
>>>str = ' abcdef '
>>>print Str[2:4]
The sequence of Python reading notes