Guest User

Untitled

a guest
Dec 7th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. def create_tuplegram(word_list):
  2. """Create a histogram composed of a list of tuples"""
  3. word_dict = {}
  4.  
  5. for word in word_list:
  6. if word in word_dict:
  7. word_dict[word] += 1
  8. else:
  9. word_dict[word] = 1
  10.  
  11. sort = sorted(word_dict.items(), key=itemgetter(1), reverse=True)
  12. return sort
Add Comment
Please, Sign In to add comment