Python List index() Method

  • Post category:List

The index() method returns the index of the first element with the specified value.

In this blog post, you will learn how to use the python list index() method.

Step 1: Create a list

my_list = [1, 2, 3, 4, 5]

Step 2: Print the index of the list

print(my_list.index(3))

Output:

2