title: Filtering a list of dictionaries by a list of substrings
body: <p>Having spent the morning looking at similar questions, I need a little help finishing my filter on a list of dictionaries.</p>
  
  <p>I have a list of dictionaries returned from an API call that I want to filter to return the lists where the 'name' value contains certain substrings. </p>
  
  <p>The following code half works.. it returns only the job.names that contain the final substring in the list: ("-upload"). </p>
  
  <pre><code>def filter():
      list_of_dicts = server.get_jobs()
      foo = ["-cb", "-audit", "-upload"]
      for f in foo:
          filtered = [d for d in list_of_dicts if f in d["name"]
      return render_template("testing.html", jobs=filtered)
  </code></pre>
  
  <p>For the sake of completeness this is passed to:</p>
  
  <pre><code>{% for job in jobs %}
     &lt;p&gt;Job: {{job.name}}&lt;/p&gt;
  {% endfor %}
  </code></pre>
  
  <p>I have tried initialising an empty list before the for loop and appending the filtered variable to it, however I always get the error = 'generator object' has no attribute 'items':</p>
  
  <pre><code>def filter():
      list_of_dicts = server.get_jobs()
      foo = ["-cb", "-audit", "-upload"]
      for f in foo:
          result = []
          filtered = [d for d in list_of_dicts if f in d["name"]
          result.append(filtered)
      return render_template("testing.html", jobs=result)
  </code></pre>