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:
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python id()
Python print()
Python Program to Convert Two Lists Into a Dictionary
Python Data Types
Python Program to Find the Size (Resolution) of a Image
Python String encode()
Python Program to Check If Two Strings are Anagram
Debug a JavaMail Program
Python Program to Make a Simple Calculator
Python frozenset()
Python Program to Create Pyramid Patterns
Python Program to Get the File Name From the File Path
Python Program to Get the Class Name of an Instance
Python float()
Python datetime
Python Dictionary popitem()
Python String rsplit()
Python List clear()
Python Program to Find Sum of Natural Numbers Using Recursion
Python Program to Find Numbers Divisible by Another Number
Python Program to Check if a Number is Odd or Even
Python for Loop
Python object()
Python String format()
Python Closures
Python String center()
Python reversed()
Python Statement, Indentation and Comments
Python Get Current time
Python String count()
Python Program to Check the File Size