Skip to content

Instantly share code, notes, and snippets.

@cosinekitty
Created April 24, 2020 21:05
Show Gist options
  • Select an option

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

Select an option

Save cosinekitty/eeca70dcc6f824db6783211740a49098 to your computer and use it in GitHub Desktop.
Illustration of why the Tally function's use of a default argument is broken.
GlobalCount = {}
def Tally(text, count = GlobalCount):
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