Tuples in Python

Tuples are used to store multiple values in a single variable just like an array. 

A tuple can consist items/value of any datatype and the data will be indexed starting with 0. 

Tuple are always written using common brackets "()".

Syntax:

tuplename = ('value1','value2',....,'valueN')

Example:

fundalist = ('funda','of','web','it')

for x in fundalist:    
    print(x)

 Output for the above code will be :

funda
of
web
it

You can check the datatype of a variable by writing the variable name in the type().

fundalist = ('funda','of','web','it')

print(type(fundalist))

Output for the above code will be :

<class 'tuple'>

Always Remember:

  • Tuples are stored in an ordered manner and have index numbers starting from 0.
  • Tuples can store same data-value/items more than once.
  • Tuples can not be changed once they are created. No operations such as insert or delete can be performed on the tuples.