Separate names with a comma.
from collections import Counter from pprint import pprint r = Counter([x.strip() for x in open('words.txt').readlines() if x.strip()]) pprint(r)