Created
November 18, 2014 02:12
-
-
Save mkowoods/e24e67782c39b0ccf394 to your computer and use it in GitHub Desktop.
Quick Letter Count Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def letter_frequency(text): | |
wdct = {} | |
for n in text: | |
m = n.lower() | |
if m.isalpha(): | |
wdct[m] = wdct.get(m, 0) + 1 | |
return sorted([(k,v) for k,v in wdct.iteritems()], key = lambda x : (-x[1], x[0])) | |
result = letter_frequency('IWT LDGAS XH HIXAA P LTXGS EAPRT, STHEXIT BN TUUDGIH ID BPZT RATPG PCS ETGUTRI HTCHT DU XI.') | |
print result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment