Created
March 14, 2019 19:14
-
-
Save craigderington/8ede956f2846f4d956e3bceaae411dfc to your computer and use it in GitHub Desktop.
Python - Check Array Frequency
This file contains 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
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