Skip to content

Instantly share code, notes, and snippets.

@chilismaug
Created April 1, 2019 19:34
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 chilismaug/3cf247309207cf2b7ec9d5f55736e3c7 to your computer and use it in GitHub Desktop.
Save chilismaug/3cf247309207cf2b7ec9d5f55736e3c7 to your computer and use it in GitHub Desktop.
py word count
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