Tkinter

Python Tuples

Python Tuples

A tuple is a list-like collection of Python objects. A tuple is a collection of values that can be of any type and are indexed by integers.

'Commas' are used to separate the values of a tuple. It is customary to define a tuple by terminating the series of values in parentheses, even if it is not required. This makes understanding Python tuples a lot easier.

Tuple Operations at a Basic Level

Tuples respond to the and * operators the same way that strings do; they mean concatenation and repetition, but the result is a new tuple rather than a string.

Indexing, Slicing, and Matrixes

Due to the fact that tuples are sequences, indexing and slicing work in the same way as they do for strings. Assume the following scenario: