Skip to content

Instantly share code, notes, and snippets.

@tfolkman
Last active October 26, 2019 02:31
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 tfolkman/e213646de032dc6e1bbd1b326c813aad to your computer and use it in GitHub Desktop.
Save tfolkman/e213646de032dc6e1bbd1b326c813aad to your computer and use it in GitHub Desktop.
defaultdict
from collections import defaultdict
my_default_dict = defaultdict(int)
for letter in 'the red fox ran as fast as it could':
my_default_dict[letter] += 1
print(my_default_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment