title: How to remove a string from a list of strings if its length is lower than the length of the string with max length in Python 2.7?
body: <p><em>How to remove a string from a list of strings if its length is lower than the length of the string with max length in Python 2.7?</em></p>
  
  <p>Basically, if I have a list such as:</p>
  
  <pre><code>test = ['cat', 'dog', 'house', 'a', 'range', 'abc']
  max_only(test)
  </code></pre>
  
  <p>The output should be:</p>
  
  <pre><code>['house', 'range']
  </code></pre>
  
  <p>'cat''s length is 3, 'dog' is 3, 'house' is 5, 'a' is 1, 'range' is 5, 'abc' is 3. The string with the highest length are 'house' and 'range', so they're returned.</p>
  
  <p>I tried with something like this but, of course, it doesn't work :)</p>
  
  <pre><code>def max_only(lst):
      ans_lst = []
      for i in lst:
          ans_lst.append(len(i))   
          for k in range(len(lst)):
              if len(i) &lt; max(ans_lst):
                  lst.remove(lst[ans_lst.index(max(ans_lst))])
      return lst
  </code></pre>
  
  <p>Could you help me?</p>
  
  <p>Thank you.</p>
  
  <p><strong>EDIT: What about the same thing for the min length element?</strong></p>