Python Tuple
Tuple is a read-only or immutable collection type in Python. It can contain any python object with sequential indexes and without worrying about duplicates. It is denoted by (values, ...)
Python Tuple Properties
- Tuple is a sequential collection.
- Tuple may have duplicate values.
- Tuple is an immutable or read-only list.
Single Value Tuple Representation
Tuple with only one value must have, after value.
>>> a = 1
>>> b = (1,)
Python Tuple Attributes
Tuple has built-in functions for read-only operations unlike list:
- count(value): Returns the count of a given value or 0 if not found.
- index(value): Returns the index of a given value or IndexError if not found.