Python 3-Tuples

Python Tuples

Tuple is the collection of objects but immutable(changeable). The following is the representation of tuple object:

Syntax -> var = (value1, value2, value3)

  • In tuple object, we cannot perform any write operations. 
  • We can perform only read operations in python tuple objects.
  • To access the elements in tuple we can use the indexing.
  • We can access the elements also through for loop.

Following is the example for Python tuples,

>>> a = (1,2,3,4)
>>> a[0]
1
>>> for i in a:
...     print (i)
...
1
2
3
4
>>>