Dictionaries and Tuples

Another application of tuples is to use them as keys in dictionaries. Follow and practice the examples presented in this section in order to understand how tuples can be used with dictionaries.


12.9 Glossary


An immutable sequence of elements.

tuple assignment:

An assignment with a sequence on the right side and a tuple of variables on the left. The right side is evaluated and then its elements are assigned to the variables on the left.


An operation that collects multiple arguments into a tuple.


An operation that makes a sequence behave like multiple arguments.

zip object:

The result of calling a built-in function zip; an object that iterates through a sequence of tuples.


An object that can iterate through a sequence, but which does not provide list operators and methods.

data structure:

A collection of related values, often organized in lists, dictionaries, tuples, etc.

shape error:

An error caused because a value has the wrong shape; that is, the wrong type or size.