How Can We Help?
Introduction:
In this tutorial, we are going to explain how to use Python list index() Method with basic syntax and many examples for better understanding.
Python list index() method It returns the lower index value of passed object in the list, if object is present in the list.
Syntax:
<list_variable_name>.index(object)
Input Parameters:
- object : is a element of list whose index to be found.
- list_variable_name : The lists that we want to count a particular element inside.
Example
alphabet=['a','b','c','d'] print("Index of c: ",alphabet.index('c'))
Output of example
Index of c: 2
In the above example, By using index() method as ” alphabet.index(‘c’)”, we can easily find the index of element ‘c’ in the list variable ‘alphabet’.
In this tutorial, you have learned how to the lower index value of passed object in the list using Python list index() method.
Hopefully, it was clear and concise.
If you have an inquiry or doubt don’t hesitate to leave them in the comment section. we are waiting for your feedback.
Similar Python list Methods:
- list.append(object) : It appends object to the given list.
- list.count(object) : It returns count of how many times object occurs in the list.
- list.extend(seq) : It appends object to the given list.
- list.insert(index,object) : It inserts object into the list at offset index.
- list.pop(obj=list[-1]) : It removes last object from the list and returns removed object of a list.
- list.remove(object) : It removes object from the list.
- list.reverse() : It reverses objects of list in place.
- list.sort([func]) : It sorts objects of a list and use compare func, if given.
Python tutorials list:
- Python tutorials list : access all python tutorials.