A tuple is an ordered sequence like a list, but immutable: once created, its items cannot be added, removed or replaced. You usually write a tuple with parentheses and commas, point = (3, 4), but it is actually the comma that makes a tuple. t = 1, 2, 3 (tuple packing) creates a tuple without parentheses. An empty tuple is () or tuple(), and tuple("ab") gives ('a', 'b'), just as tuple([1, 2]) gives (1, 2). Tuples exist because many values naturally belong together and should not change: a coordinate, a date, an RGB (red, green, blue) colour.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.