In this example, you will learn to count the occurrence of an item in a list.
To understand this example, you should have the knowledge of the following Python programming topics:
Using count() method
freq = ['a', 1, 'a', 4, 3, 2, 'a'].count('a')
print(freq)
Output
3
Using count() method, pass the item to be counted. As shown above, 'a' is passed, which gives the total number of occurrences of character 'a'.
You can learn more about count() at Python count().
Related posts:
Python String isnumeric()
Python Dictionary
Deep Learning with Python - Francois Chollet
Python String rpartition()
Python max()
Python String isprintable()
Python exec()
Python delattr()
Python String casefold()
Python Program to Get a Substring of a String
Python Set difference_update()
Python Program to Parse a String to a Float or Int
Python String partition()
Python Program to Find the Factorial of a Number
Python zip()
Python List clear()
Python String rindex()
Python Dictionary setdefault()
Python frozenset()
Python List remove()
Python Program to Find Armstrong Number in an Interval
Python String islower()
Python Set intersection()
Python range()
Python memoryview()
Python Input, Output and Import
Python Get Current time
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python Set update()
Python Program to Convert Celsius To Fahrenheit
Python String capitalize()
Python min()