The list is the most flexible data type in Python, it represents an ordered collection of elements in which elements can appear more than once.

The count() method is used to get the number of times that an element appears in a list.

ExampleEdit & Run
mylist = ['a', 'b', 'a', 'c', 'a', 'a', 'a']

#get the number of times 'a' appears in the list
x = mylist.count('a')
print(x)
Output:
5[Finished in 0.010481978999450803s]

The syntax of the count() method is as shown below:

Syntax:
lst.count(item)
item The element whose count we want.

The count() method returns an integer representing the number of times the input item appears in the list. 

ExampleEdit & Run
mylist = ['Python', 'Java', 'C++', 'Python']

print(mylist.count('Python'))
Output:
2[Finished in 0.010357704013586044s]

Count how many time each element appears in a list

If we want to check the count of each element in a list  we can use list comprehension to conveniently count the elements.

ExampleEdit & Run
mylist = ['orange', 'apple', 'orange', 'lemon', 'lemon', 'orange', 'apple', 'orange', 'apple']

counts = [(item, mylist.count(item)) for item in set(mylist)]

print(counts)
Output:
[('lemon', 2), ('apple', 3), ('orange', 4)][Finished in 0.010564778931438923s]

In the above example, we used list comprehension to create a list of tuples in which each tuple is in the form (element, count) for each unique element of the list.