Skip to content

Instantly share code, notes, and snippets.

@aitskovi
Created February 8, 2015 16:27
Show Gist options
  • Save aitskovi/fdb955c607e4a6b98057 to your computer and use it in GitHub Desktop.
Save aitskovi/fdb955c607e4a6b98057 to your computer and use it in GitHub Desktop.
def incrementcount(word):
if wordcounts.get(word):
wordcounts[word] += 1
else:
wordcounts[word] = 1
# Can be replaced with:
wordcounts[word] = wordcounts.get(word, 0) + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment