You can find the number of elements with the specified value in a list in Python by following the given step. If you want to learn Python then I will highly recommend you to read This Book.
Step 1
Count Method is used to find the number of elements with the specified value in list in Python. In the given example, ‘a’ is the variable in which list is store. To count that how many times the specific value occur in the list I will use the following code.
a = [1,2,2,3,2,4,5,2,1] print(a) print(a.count(2)) print(a.count(1))
People are also reading:
What is Computer Vision? Examples, Applications, Techniques