Created
March 9, 2013 00:07
-
-
Save chriszf/5121546 to your computer and use it in GitHub Desktop.
letter count
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 count(filename): | |
f = open(filename) | |
text = f.read() | |
text.lower() | |
letters = [0] * 26 | |
for letter in text: | |
index = ord(letter) - ord("a") | |
if index >= 0 and index < 26: | |
letters[index] += 1 | |
return letters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment