 <p>You can use regular expressions to match any of the bad words:</p> <pre><code>is_bad = re.search('|'.join(bad_words), bad_string) != None </code></pre> <p><code>bad_string</code> is the string to test, <code>is_bad</code> is <code>True</code> or <code>False</code>, depending on whether <code>bad_string</code> has bad words or not.</p>