Skip to content

Computer Science · Ch 10 — Tuples and Dictionaries

Tuple Operations

10.2

Tuple Operations

Tuples support the same family of sequence operations you have already used with strings and lists. This section groups them into four operations, each covered in its own sub-section:

  • 10.2.1 Concatenation — joining two tuples with the + operator (and using it to extend an existing tuple).
  • 10.2.2 Repetition — repeating a tuple's elements with the * operator.
  • 10.2.3 Membership — testing whether an element is present using in and not in.
  • 10.2.4 Slicing — extracting a part of a tuple with the [start:stop:step] notation. …