def frequencies(filename, top_n):
    with open(filename) as infile:
        content = infile.read()
invalid = """‘'`,.?!:;-_
—' '"""
counter = Counter([x for x in content if not invalid.__contains__(x)])
for letter, count in counter.most_common(top_n):
    yield '{:8} appears {} times.'.format(letter, count)
I'm trying to count all letters in a txt file then display in descending order