Tuple Methods
Tuples are ordered fixed-size values. Tuple methods are pure.
See Values And Types for tuple literal forms such as (),
(x,), and (x, y).
Signatures
Section titled “Signatures”| Method | Returns | Notes |
| ----------------------------- | -------------- | -------------------------------------------------------- |
| xs.index(value) | num \| err | First structurally equal index, or ValueError/NLK4002. |
| xs.index(value, start) | num \| err | First index at or after start, or error. |
| xs.index(value, start, end) | num \| err | First index in the normalized range, or error. |
| xs.count(value) | num | Count of structurally equal items. |
| xs.get(index) | value | err | Item, or IndexError/NLK4004 on a miss. |
Errors
Section titled “Errors”index() returns ValueError/NLK4002 when the value is absent. start and end must be integers.
Negative start and end values are normalized from the end. index() and count() use
structural equality.
Raw tuple indexing is fatal on a miss. get() is the safe value-level alternative. Errors cannot
participate in index() or count(), including through a containing value.
Tuples support indexing, slicing, concatenation, repetition, conversion, and destructuring, but not item assignment.
Examples
Section titled “Examples”pair = ("nilakan", 1)print(pair[0])print(pair.count("nilakan"))print(pair.index(1))