How to count occurrences of an item in a list in Python

· 1 min read · Updated March 16, 2026 · beginner
python lists counting

The simplest way to count occurrences is with the built-in count() method:

items = [1, 2, 2, 3, 2, 4, 2]
print(items.count(2))  # 4
print(items.count(5))  # 0

This works for any hashable type:

words = ["apple", "banana", "apple", "cherry", "apple"]
print(words.count("apple"))  # 3

Using Counter for Multiple Counts

When you need to count all unique elements at once, use Counter from collections:

from collections import Counter

items = [1, 2, 2, 3, 2, 4, 2]
counts = Counter(items)
print(counts)  # Counter({2: 4, 1: 1, 3: 1, 4: 1})
print(counts.most_common())  # [(2, 4), (1, 1), (3, 1), (4, 1)]

Manual Loop

For maximum control, use a simple loop:

def count_occurrences(lst, item):
    count = 0
    for element in lst:
        if element == item:
            count += 1
    return count

print(count_occurrences([1, 2, 2, 3, 2], 2))  # 3

See Also