Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. Tuples in python
  5. Introduction of Tuple in python

Introduction of Tuple in python

The python tuples are sequence that are used to store a tuple of values of any type. It is similar to list except we used parenthesis instead of square bracket.

Tuples are immutable i.e., you cannot change the elements of a tuple in place.

A tuple is a standard datatype of python that can store a sequence of values belonging to any type.

Creating a tuple is similar to list creation, but we use parenthesis instead of square bracket. Use round brackets to indicate the start and end of the tuple, and separate the items by commas.

e.g.,

t=(1,2,3,4,5,6)
print(type(t))
Output- class <tuple>

If a tuple contains an element which is a tuple itself then it is called nested tuple.

e.g.,

t=(1,2,3,4,(5,6))
print(type(t))
Output- class <tuple>
Was this article helpful to you? Yes No

How can we help?