Skip to content

Instantly share code, notes, and snippets.

@bbengfort
Created September 13, 2014 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbengfort/d10f139ae15d90950ddf to your computer and use it in GitHub Desktop.
Save bbengfort/d10f139ae15d90950ddf to your computer and use it in GitHub Desktop.
Afternoon Example for Georgetown Software Engineering Cohort II
def word_count(path):
counts = {
'line': 0,
'word': 0,
'char': 0
}
with open(path, 'r') as f:
for line in f:
counts['line'] += 1
counts['char'] += len(line)
counts['word'] += len(line.split())
return counts
if __name__ == '__main__':
print word_count('shakespeare.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment