from collections import Counter def main(): with open('lyrics_pan_nanpa_wan.txt') as f: lyrics = f.read() alphabetic_only = ''.join([c for c in lyrics if c.isalpha() or c == ' ']) words = alphabetic_only.split() print(Counter(words)) print(len(Counter(words))) if __name__ == '__main__': main()