count values and number of times the values in list python code example
Example 1: count the number of times a value appears in python
# 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: count the number of times a value appears in python
The count of i is: 2
The count of p is: 0