Python - Check if two words are in a string
<p>I would like to check whether 2 words "car" and "motorbike" are in each element of an array in Python. I know how to check for one word with <code>in</code> but have no idea how to do with 2 words. Really appreciate any help</p>

<p>Two word solution:</p>

<pre><code>for string in array:
    if 'car' in string and 'motorbike' in string.split():
        print("Car and motorbike are in string")
</code></pre>

<p>n-word solution to check if <strong>all</strong> words in <code>test_words</code> are in <code>string</code>:</p>

<pre><code>test_words = ['car', 'motorbike']
contains_all = True

for string in array:
    for test_word in test_words:
        if test_word not in string.split()::
            contains_all = False
            break
    if not contains_all:
        break

if contains_all:
    print("All words in each string")
else:
    print("Not all words in each string")
</code></pre>

python