public
Created

  • Download Gist
letters.py
Python
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/env python3
# Counts the amount of letters in a file.
# In this case, used to count the concentration of letters in English.
import string
from collections import Counter
 
c = Counter(string.ascii_lowercase + string.ascii_uppercase)
 
with open('/usr/share/dict/words', 'r') as words:
for word in words:
map(lambda l: c.__setitem__(l, c[l] + 1), tuple(word.strip())) # Tuples are faster than lists
print c

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.