How Can We Help?
Introduction:
In this tutorial, we are going to explain how to use Python list count() Method with basic syntax and many examples for better understanding.
Python list count() method It returns count of how many times object occurs in the list.
Syntax:
<list_variable_name>.count(object)
Input Parameters:
- object : is a single element which to be counted in the list.
- list_variable_name : The lists that we want to count a particular element inside.
Example
myList = [12, 'Java', 12, 'Python',3] print ("12 count : ", myList.count(12))
Output of example
12 count : 2
In the above example, we can easily count the number of times ’12’ occur in the list variable myList by using command as ” myList.count(12)”.
In this tutorial, you have learned how to how many times object occurs in the list by using Python list count() 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.extend(seq) : It appends the contents of sequence to the list.
- list.index(object) : It returns the lower index value of passed object in the list, if object is present in the 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.