Write a Python program to find the index of an item of a tuple


The program defines a tuple a containing 8 integer elements. The print() function is used to output the index numbers of two values (78 and 34) within the tuple a. The index() method is used to find the index number of a specific value in the tuple. It returns the index of the first occurrence of the value in the tuple.

The first print() statement outputs the index number of the value 78 in the tuple a by calling a.index(78). The second print() statement outputs the index number of the value 34 in the tuple a by calling a.index(34). As a result, the output will show the index numbers of the values 78 and 34 in the tuple a.

Source Code

#    0   1  2  3  4  5  6  7
a = (23,45,67,78,89,90,34,56)
print("Index Number :",a.index(78))
print("Index Number :",a.index(34))

Output

Index Number : 3
Index Number : 6


Example Programs