Google News
logo
Python Program to Access tuple items
In the following example of Python program to access tuple items :
Program :
# Create a tuple
my_tuple = ('apple', 'banana', 'cherry', 'orange')

# Accessing items of a tuple
print(my_tuple[0])
print(my_tuple[1])
print(my_tuple[2])
print(my_tuple[3])
Output :
apple
banana
cherry
orange
In the above program, we first created a tuple called `my_tuple` with four items : 'apple', 'banana', 'cherry', and 'orange'.

We then accessed the items of the tuple using their index values.

Tuple indexing starts at 0, so `my_tuple[0]` gives the first item ('apple'), `my_tuple[1]` gives the second item ('banana'), and so on.