Created
October 9, 2012 18:37
-
-
Save chriszf/3860594 to your computer and use it in GitHub Desktop.
Exercise 09 Solution
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 main(): | |
f = open("twain.txt") | |
text = f.read() | |
f.close() | |
text = text.lower() | |
num_letters = [0] * 26 | |
for letter in text: | |
ascii_code = ord(letter) - 97 | |
if 0 <= ascii_code < 26: | |
num_letters[ascii_code] += 1 | |
for count in num_letters: | |
print count | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment