Closed patrickloeber closed 2 years ago
import collections item_list = ["foo", "bar", "foo", "foo", "bar", "foobar"] occurrences = collections.Counter(item_list) print(occurrences) #print(occurrences["foo"]) to print one element only
output : Counter({'foo': 3, 'bar': 2, 'foobar': 1})
assign me
output : Counter({'foo': 3, 'bar': 2, 'foobar': 1})