how to count same value in list in python code example

Example 1: python count repeated elements in a list

# Basic syntax:
dict_of_counts = {item:your_list.count(item) for item in your_list}

# Example usage:
your_list = ["a", "b", "a", "c", "c", "a", "c"]
dict_of_counts = {item:your_list.count(item) for item in your_list}
print(dict_of_counts)
--> {'a': 3, 'b': 1, 'c': 3}

Example 2: 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)