Count the occurrences of items in a collection.
Source Code
from collections import Counter
words = ["apple", "banana", "apple", "pear", "banana", "orange", "banana"]
word_counts = Counter(words)
print(word_counts)
Count the occurrences of items in a collection.
from collections import Counter
words = ["apple", "banana", "apple", "pear", "banana", "orange", "banana"]
word_counts = Counter(words)
print(word_counts)