Skip to content

Instantly share code, notes, and snippets.

@craigderington
Created March 14, 2019 19:14
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 craigderington/8ede956f2846f4d956e3bceaae411dfc to your computer and use it in GitHub Desktop.
Save craigderington/8ede956f2846f4d956e3bceaae411dfc to your computer and use it in GitHub Desktop.
Python - Check Array Frequency
the_list = [1, 3, 7, 9, 12, 3, 9, 12, 9, 10, 14, 23, 12]
def analyze_list(l):
counts = {}
for item in l:
if item in counts:
counts[item] += counts[item]
else:
counts[item] = 1
return counts
print(analyze_list(the_list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment