Python Tuple

Tuples In Python

What is tuple?

Python tuples are built-in data type. Tuples are container used to store collection of different data types in a single variable. It is always enclosed with round-bracket.


You can also change other data types into tuple.


Tuple properties

Following are the properties of tuple :

  • Ordered : Tuple items have a fixed order that can not be changed.
  • Unchangeable : Tuples items are unchangeable means elements can not be added or removed from the tuple.

  • Allow Duplicate : Tuple items can be used multiple times in the same tuple.
  • Indexed : Tuple elements can be sliced or indexed "tuple indexing or tuple slicing", just like string slicing. shown below,

Tuple Methods

Python tuple methods helps to manipulate the tuple. Following are built-in tuple methods :

  •  tuple.count()  : Used to count the number of a specific element of a tuple.
  •  tuple.index()  : Used to find the index of a specific element.



Give an example of tuple in comment section.

Comments