title: Python, Take dictionary, and produce list with (words>1, most common words, longest words)
body: <p>So i made a function</p>
  
  <pre><code>def word_count(string):
      my_string = string.lower().split()
      my_dict = {}
      for item in my_string:
          if item in my_dict:
              my_dict[item] += 1
          else:
              my_dict[item] = 1
      print(my_dict)
  </code></pre>
  
  <p>so, what this does is that it takes a string, splits it, and produces a dictionary with the key being the word, and the value being how many times it appears.</p>
  
  <p>Okay, so what im trying to do now, is to make a function that takes the output of that function, and produces a list in the following format-</p>
  
  <p>((list of words longer than 1 letter),(list of most frequent words), (list of words with the longest length))</p>
  
  <p>also, for example lets say two words have appeared 3 times, and both words are 6 letters long, it should include both words in both the (most frequent) and (longest length) lists.</p>
  
  <p>So, this has been my attempt thus far at tackling this problem</p>
  
  <pre><code>def analyze(x):
      longer_than_one= []
      most_frequent= []
      longest= []
      for key in x.item:
          if len(key) &gt;1:
              key.append(longer_than_one)
      print(longer_than_one)
  </code></pre>
  
  <p>so what i was trying to do here, is make a series of for and if loops, that append to the lists depending on whether or not the items meet the criteria, however i have run into the following problems:-</p>
  
  <p>1- how do i iterate over a dictionary without getting an error?</p>
  
  <p>2- I cant figure out a way to count the most frequent words (i was thinking to append the keys with the highest values)</p>
  
  <p>3- I cant figure out a way to only append the words that are the longest in the dictionary (i was thinking of using len(key) but it said error)</p>
  
  <p>If it's any help, im working in Anaconda's Spyder using Python 3.5.1 ,any tips would be appreciated!</p>