Write a Python program to find the index of an item in a specified list


This program uses the index() method of a list in python. It finds the first occurrence of a given element in the list and returns its index position. In this case, the list num contains the elements 20, 70, 30, 90, 10, 30, 90, 10, 80. The program calls the index() method on the list num and passes the argument 30. The method searches for the first occurrence of 30 in the list and returns its index position, which is 2. The returned value is then printed to the console.

Source Code

num = [20, 70, 30, 90, 10, 30, 90, 10, 80]
print(num.index(30))
 

Output

2

Example Programs