Last active
April 25, 2020 01:05
-
-
Save cosinekitty/f50f2254a3b5485934f0d1506793afeb to your computer and use it in GitHub Desktop.
Tally function with naive default dictionary argument.
This file contains hidden or 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
| # WARNING: This code contains a subtle bug! | |
| def Tally(text, count = {}): | |
| for c in text: | |
| count[c] = 1 + count.get(c, 0) | |
| return count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment