title: using lambda to verify all elements in list
body: <p>i have a list of foods called "my_foods". </p>
  
  <p>i would like to use a lambda function to verify that all elements from the list "good_foods" appear in the list "my_foods", and also verify that none of the elements from the list "bad_foods" appear in "my_foods".</p>
  
  <p>i can solve this with nested for loops and if statements but am curious if lambdas are more elegant.</p>
  
  <p>if "my_foods" has both "apple" and "carrot" the below executes successfully:</p>
  
  <pre><code>good_foods = ['apple', 'carrot']
  junk_foods = ['soda', 'burger']
  
  my_foods = ['banana', 'carrot', 'bread', 'apple']
  
  result = ( filter(lambda x: x in my_foods, good_foods) and
      not filter(lambda x: x in my_foods, junk_foods) )
  
  print result
  # True
  </code></pre>
  
  <p>however, if "my_foods" has only "apple" or only "carrot", then the below still returns True, and i don't want that. i want it to return False. i want to verify that all "good_foods" are in the list "my_foods":</p>
  
  <pre><code>good_foods = ['apple', 'carrot']
  junk_foods = ['soda', 'burger']
  
  my_foods = ['banana', 'carrot', 'bread']
  
  result = ( filter(lambda x: x in my_foods, good_foods) and
      not filter(lambda x: x in my_foods, junk_foods) )
  
  print result
  # True
  </code></pre>
  
  <p>additionally, if "my_foods" has neither "apple" nor "carrot", then the below returns an empty list. i want it to return False instead:</p>
  
  <pre><code>good_foods = ['apple', 'carrot']
  junk_foods = ['soda', 'burger']
  
  my_foods = ['banana', 'bread']
  
  result = ( filter(lambda x: x in my_foods, good_foods) and
      not filter(lambda x: x in my_foods, junk_foods) )
  
  print result
  # []
  </code></pre>
  
  <p>lastly, if any of the "bad_foods" is in the list "my_foods" the below executes successfully and returns False, which is what i want in this instance:</p>
  
  <pre><code>good_foods = ['apple', 'carrot']
  junk_foods = ['soda', 'burger']
  
  my_foods = ['banana', 'carrot', 'bread', 'apple', 'soda']
  
  result = ( filter(lambda x: x in my_foods, good_foods) and
      not filter(lambda x: x in my_foods, junk_foods) )
  
  print result
  # False
  </code></pre>
  
  <p>thanks for any help!</p>