https://docs.python.org/3/library/stdtypes.html#tuples
Tuples are immutable heterogeneous sequences.
+----------------------+----------------------------+ | Operation | Meaning | +----------------------+----------------------------+ | T = () ; T = tuple() | empty tuple | | T = (0,) | one item | | T = tuple([0]) | one item (from list) | | T = (1, 3, 5, 7) | four items | | T = tuple(iterable) | make tuple from iterable | | len(T) | length | | T1 + T2 | concatenation | | T * n, n * T | repetition | | T[i] | get item at index | | T[i:j] | slice of T (new tuple) | | T[i:j:k] | slice of T (new tuple) | | for item in T: pass | iteration | | item in T | containing (linear-time) | | item not in T | containing (linear-time) | | T.index(item) | first occurrence | | T.count(item) | number of occurrences | | max(T), min(T) | the largest|smallest item | | del T | remove the name T | | (x, y) = (a, b) | x = a ; y = b # assignment | +----------------------+----------------------------+
# help(tuple) T = (3, 5, 7) #T[1] = 9 # TypeError #T.append(9) # AttributeError tuple([1, 3, 5]) # (1, 3, 5) tuple("abc") # ("a", "b", "c") x, y = [1, 2] # x = 1 ; y = 2 x, y = "ab" # x = "a" ; y = "b" x, y = y, x # exchanging references, x = "b", y = "a"