Python Program 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'.


Also Read:

Did you find this article helpful?

Our premium learning platform, created with over a decade of experience and thousands of feedbacks.

Learn and improve your coding skills like never before.

Try Programiz PRO
  • Interactive Courses
  • Certificates
  • AI Help
  • 2000+ Challenges