Easy_Flex

Untitled

Mar 8th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. words = ["dangerous", "beware", "endanger", "beware", "danger", "Danger", "Beware", "Myself"]
  2.  
  3.  
  4. def length_count(words):
  5.     counts = {}
  6.     for word in words:
  7.         if len(word) in counts:
  8.             counts[len(word)] += 1
  9.  
  10.         else:
  11.             counts[len(word)] = 1
  12.  
  13.     return counts
  14.  
  15.  
  16. print(length_count(words))
Add Comment
Please, Sign In to add comment