Created
April 1, 2019 19:34
-
-
Save chilismaug/3cf247309207cf2b7ec9d5f55736e3c7 to your computer and use it in GitHub Desktop.
py word count
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
fruit = ['apple', 'avocado', 'orange', 'kiwi', 'grape', 'pineapple', 'raspberry', 'bluet', 'pineapple', 'raspberry', | |
'avocado', 'orange', 'kiwi', 'grape','apple', 'avocado', 'orange', 'kiwi', 'grape', 'pineapple'] | |
def analyze_list(l): | |
counts = {} | |
for item in l: | |
if item in counts: | |
counts[item = counts[item] + 1 | |
else: | |
counts[item] = 1 | |
return counts | |
# let's analyze a list for item occurence counts | |
# by andrew from mongo db university |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment