Python Tuples

Tuples

Tuples are used to store multiple values in a single variable. Tuples are built-in data structures in Python, similar to lists, sets, and dictionaries.

Tuples are created using round brackets ( ).

Tuples are immutable data types, meaning they cannot be modified after creation.

Ordered and Unchangeable

Tuples are ordered, which means the items have a defined sequence that will not change. Each element in a tuple has an index.

Example

Example of a Python Tuple

Output

35


Allow Duplicates

Tuples can contain items with the same value.

Example

Example of a Python Tuple with Duplicates

Output

Output of a Python Tuple with Duplicates

Tuple Length

The length of a tuple is the number of elements it contains, and it can be determined using the len() function.

Example

Example of finding length of a Python Tuple

Output

5