Skip to content

Instantly share code, notes, and snippets.

@cosinekitty
Last active April 25, 2020 01:05
Show Gist options
  • Select an option

  • Save cosinekitty/f50f2254a3b5485934f0d1506793afeb to your computer and use it in GitHub Desktop.

Select an option

Save cosinekitty/f50f2254a3b5485934f0d1506793afeb to your computer and use it in GitHub Desktop.
Tally function with naive default dictionary argument.
# 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