top of page

Python Programming Help

Public·2 members

How can I Count The Occurrences Of Each Item Present In The List ?

Hi Everyone !


Welcome to codersarts....


Here Codersarts would provide top rated python program which help to improve your coding skills


So, Lets go ahead ..


Here we count repeated item in python list using count() method.


count()


count() method counts how many times an element has occurred in a list and returns it.


syntax


list.count(element)

Parameters


The count() method takes a single argument:


  • element - element whose count is to be found.

Return value


The count() method returns the number of occurrences of an element in a list.


Example:


# vowels list
vowels = ['a', 'e', 'i', 'o', 'i', 'u']

# count element 'i'
count = vowels.count('i')

# print count
print('The count of i is:', count)

# count element 'p'
count = vowels.count('p')

# print count
print('The count of p is:', count)

Output:


The count of i is: 2
The count of p is: 0

For other top rated Codersarts python program links:



For other top rated python program visit here


If you like Codersarts blog and looking for Assignment help,Project help, Programming tutors help and suggestion  you can send mail at contact@codersarts.com.

Please write your suggestion in comment section below if you find anything incorrect in this blog post 


147 Views
bottom of page