Tuple is another ordered list, and Chinese is translated as "tuple". Tuple and list are very similar, however, once a tuple is created, it cannot be modified.
The same is the name of the class, expressed as a tuple as follows:
>>> t = (' Adam ', ' Lisa ', ' Bart ')
The only difference between creating a tuple and creating a list is the ( )
substitution [ ]
.
Now, this t
cannot be changed, the tuple has no append () method, and there is no insert () and Pop () method. Therefore, the new classmate can not directly add to the tuple, old classmates want to quit a tuple also not.
The way to get a tuple element is exactly the same as the list, and we can access the element normally using indexed methods such as t[0],t[-1], but cannot be assigned to any other element, but it is not believed to try:
>>> t[0] = ' Paul ' Traceback (most recent): File "<stdin>", line 1, in <module>typeerror: ' Tuple ' object does not support item assignment
The above content transferred from MU class net, only for individual study!
Create a tuple of Python