In this tutorial, learn how to find the index of given element of list Using Python. The short answer is: use the Python index() to get the index of the list element.

In the list, the elements are sequentially arranged in the order using the index. The elements in the list are indexed which starts from zero(0). Each element of the list are enclosed within the square bracket([]). You may also like to read how to change or reverse list element using Python.

How to Find the Index of Given Element of List in Python

If you want to get the index of the element given in the list, you have to use the Python index(). The function takes one argument to pass to get the index. You have to pass the list element as the argument of the index() function.

You can find the index of given element of the list with one index at a time. If you want to get the index of more elements, you have to use the index() function many times. Check the example given below to get the idea of getting index of elements.

Output

0
1
2
4

The above example showing the use of index function to get the index of the element. By using the above example, you can find the index of any type of element given in the list.

The given example find the index of the string element as well as the integer element. The output showing the index value of the element given in the list.

Hope, you like this post of how to find the index of given element of list in Python. If you have any query regarding the tutorial, please comment below.

Also tell me, which method you are using to get the index of the list element.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.