Skip to content

Instantly share code, notes, and snippets.

@Sunil-ghodela
Created August 21, 2019 18:56
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 Sunil-ghodela/1c7fac55ed22de14aab8be3358ad4044 to your computer and use it in GitHub Desktop.
Save Sunil-ghodela/1c7fac55ed22de14aab8be3358ad4044 to your computer and use it in GitHub Desktop.
Frequency of list item in a list
we = ['a', 'w', 'a', 'i']
temp_dict = {}
for w in we:
no_count = temp_dict.get(w, '')
if no_count == '':
temp_dict[w] = 1
else:
temp_dict[w] = no_count+1
for e in temp_dict.keys():
print(e + ':' + str(temp_dict.get(e)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment