The count method
The count method returns the number of matches of an element in the list. In the method parameter, we pass the element we want to find.
Syntax
list.count(what are we looking for)
Example
Let's find out how many times a string appears in our list:
lst = ['a', 'b', 'c', 'd', 'e']
print(lst.count('a'))
Result of code execution:
2
Example
Now let's find the missing element in the list:
lst = ['a', 'b', 'c', 'd', 'e']
print(lst.count('x'))
Result of code execution:
0