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:
Learn Python practically
and Get Certified.
Created with over a decade of experience.
Created with over a decade of experience and thousands of feedback.
Learn Python practically
and Get Certified.
To understand this example, you should have the knowledge of the following Python programming topics:
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:
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