from collections import Counter

karta = Counter()

for pituh in ("foo", "bar", "foo"):
    karta[pituh] += 1

print(karta)