About tuple:
- Tuples and lists are similar, but the data tuple can not be amended.
- Tuple is a pair ()
Tuple operations:
- Tuples can not be amended so few operations tuple
- Define the empty tuple (a tuple because once created, the data can not be modified, thus creating little empty tuple)
info_tuple = ()
- Element defines a tuple
info_tuple = (20,)
When you create a tuple of elements behind the elements should be added a comma, if you forget to add the words, not the creation of a tuple but a variable, such as:
- Yuan Group Length
info_tuple = (1, 2, 5)
only (info_tuple) - Value, whichever index
= info_tuple (. 1, 2,. 5 ) # value Print (info_tuple [. 1 ]) # fetch index Print (info_tuple.index (. 1))
- Statistical same element occurrences
info_tuple = (1, 2, 5, 2) print(info_tuple.count(2))
- List and tuple into each other