Question: ```
search_terms = ['word','cow','horse']

library = [['desk','chair','lamp'],['cow','horse','word 223','barn']]

```

I want to be able to print all list(s) in library that contain ALL of the terms in search\_terms. 

so using the above list of search\_terms would print the second sublist in library even though 'word 223' just contains 'word', but is not a direct match. 

I will not always have the same number of strings...

Thanks for anyone who is willing to help me!

and thanks to falsetru for helping me with my first question!

Answer: 
To get your hits, use a list comprehension:

```
search_terms = ['word', 'cow', 'horse']

library = [['desk', 'chair', 'lamp'],
           ['cow', 'horse', 'word 223', 'barn']]

hits = [l for l in library if 
        all(any(t in s for s in l) 
            for t in search_terms)]

```

This works as follows

1. `for` each sub-list `l` in your `library`;
2. `for` `all` terms `t` in `search_terms`;
3. `if` `any` of the strings `s` in `l` contains it;
4. Keep `l` in the new list `hits`.
```
>>> search_terms = ['word','cow','horse']
>>> library = [['desk','chair','lamp'],['cow','horse','word 223','barn']]
>>> from itertools import chain
>>> list(chain(*library))
['desk', 'chair', 'lamp', 'cow', 'horse', 'word 223', 'barn']
>>> [word for word in search_terms if word in list(chain(*library))]
['cow', 'horse']
>>> [l for l in library if any(word for word in search_terms if word in l)]
[['cow', 'horse', 'word 223', 'barn']]

```