how to count equal elements in list python code example
Example 1: python count list
# 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)
Example 2: python count occurrences of an item in a list
>>> [1, 2, 3, 4, 1, 4, 1].count(1)
3