Use any for this:

>>> s = 'blahblahAA'
>>> any(x not in s for x in ('AA', 'BB', 'CC'))
True

Your current code is equivalent to:

if ('AA') or ('BB') or ('CC' not in string)

As 'AA' is True(bool('AA') is True), so this always evaluates to True.

Answer from Ashwini Chaudhary on Stack Overflow
Discussions

python - Check if multiple strings exist in another string - Stack Overflow
How can I check if any of the strings in an array exists in another string? For example: a = ['a', 'b', 'c'] s = "a123" if a in s: print("some of the strings found in s") el... More on stackoverflow.com
🌐 stackoverflow.com
How to check if any element in a list contains a substring
If you don't need to know exactly which element(s) contain the substring, then you could use the any built-in function in combination with a list comprehension l = ["Hey dude", "Hey bro", "Sup dude", "Hey bud"] substring = "Sup" if any([substring in element for element in l]): print(f"One or more elements of {l} contain the substring {substring}") else: print(f"No elements of {l} contain the substring {substring}") Here's an explanation about the any function. Alternatively, switch out any for all if you want to check if all the elements of the list contain the substring. all documentation More on reddit.com
🌐 r/learnpython
18
11
October 28, 2019
Checking whether multiple substrings are within a string?
You could use the builtin any function and a generator expression - something like this: if any(s in f for s in ("_F_", "_F.", "_R_","_R.")): print("Success") More on reddit.com
🌐 r/learnpython
9
2
October 24, 2016
How do I check if string contains all substrings in list?

You could try

if all([val in string for val in list]):

Which checks the truth of each check and returns True only if all are True. Otherwise you're looking at a loop (or if your lists get really big a generator).

More on reddit.com
🌐 r/learnpython
11
1
November 16, 2018
🌐
Real Python
realpython.com › python-string-contains-substring
How to Check if a Python String Contains a Substring – Real Python
December 1, 2024 - If you need to check whether a string contains a substring, use Python’s membership operator in. In Python, this is the recommended way to confirm the existence of a substring in a string: ... >>> raw_file_content = """Hi there and welcome. ... This is a special hidden file with a SECRET secret. ... I don't want to tell you The Secret, ... but I do want to secretly tell you that I have one.""" >>> "secret" in raw_file_content True
🌐
Note.nkmk.me
note.nkmk.me › home › python
Search for a String in Python (Check If a Substring Is Included/Get a Substring Position) | note.nkmk.me
May 7, 2023 - You can check for the presence of multiple substrings using and and or. ... s = 'I am Sam' print('Sam' in s) # True print('sam' in s) # False print('I' in s and 'Sam' in s) # True ...
🌐
Statology
statology.org › home › pandas: check if string contains multiple substrings
Pandas: Check if String Contains Multiple Substrings
October 10, 2022 - We can use the following syntax to check if each string in the team column contains either the substring “Good” or “East”:
🌐
Bobby Hadz
bobbyhadz.com › blog › python-check-if-multiple-strings-exist-in-another-string
Check if multiple Strings exist in another String in Python | bobbyhadz
April 9, 2024 - Copied!my_str = 'apple, egg, avocado' list_of_strings = ['apple', 'banana', 'kiwi'] one_exists = False for substring in list_of_strings: if substring in my_str: one_exists = True break print(one_exists) # 👉️ True if one_exists: # 👇️ this runs print('At least one of the substrings is contained in the string') else: print('None of the substrings are contained in the string')
Find elsewhere
🌐
LearnDataSci
learndatasci.com › solutions › python-string-contains
Python String Contains – See if String Contains a Substring – LearnDataSci
The easiest and most effective way to see if a string contains a substring is by using if ... in statements, which return True if the substring is detected. Alternatively, by using the find() function, it's possible to get the index that a substring starts at, or -1 if Python can't find the ...
🌐
Analytics Vidhya
analyticsvidhya.com › home › learn how to check if a string contains a substring in python
Learn How to Check If a String Contains a Substring in Python - Analytics Vidhya
January 10, 2024 - One or more substrings not found. When dealing with Unicode characters, handling them properly while checking for substrings is important. Python provides various encoding and decoding methods to handle Unicode characters. Here’s an example: ... string = "Héllö, Wörld!" substring = "éll" if substring in string: print("Unicode substring found!") else: print("Unicode substring not found.")
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-check-if-string-contains-another-string
How To Check If a String Contains Another String in Python | DigitalOcean
April 9, 2026 - You can use the in operator, the find() method, or regular expressions to check if a string contains a substring in Python. The in operator returns True if the substring is found, while the find() method returns the index of the first occurrence of the substring, or -1 if it’s not found.
🌐
Net Informations
net-informations.com › python › basics › multiple.htm
Check if multiple strings exist in another string : Python
In Python, to check if multiple strings exist in another string, you can use various approaches like the "in" operator, regular expressions, or custom functions. Let's explore these methods with examples: The "in" operator allows you to check if individual substrings exist within a given string.
🌐
TutorialsPoint
tutorialspoint.com › How-to-check-if-multiple-strings-exist-in-another-string-in-Python
How to check if multiple strings exist in another string in Python?
The given string is Welcome to Tutorialspoint Checking if the string contains the given strings ['a', 'b', 'c', 'd', 'e'] True · The Python all() function returns true if all the elements of the given iterable are truthy, otherwise it returns false. In this scenario, we are using the generator ...
🌐
sqlpey
sqlpey.com › python › python-check-multiple-substrings
Python: Efficiently Check for Multiple Substrings in a String
July 22, 2025 - Combined with a generator expression, it provides a concise and efficient way to test for substring presence. main_string = "The quick brown fox jumps over the lazy dog." search_terms = ["fox", "cat", "bird"] if any(term in main_string for term in search_terms): print("At least one search term found!") else: print("No search terms found.")
🌐
FavTutor
favtutor.com › blogs › string-contains-substring-python
Check if Python string contains substring: 3 Methods (with code)
January 23, 2023 - You can use the .findall() function instead of .search() function to find every matching substring that ends with punctuation. Python has __contains__() as an instance method to check for substrings in a string.
🌐
Metaschool
metaschool.so › home › software development › master string searches in python 2025
Master String Searches in Python 2025
February 7, 2025 - 1. Use the in keyword, which returns True if the substring is present within the string. 2. Use str.find(), which returns the index of the first occurrence of the substring or -1 if not found.
🌐
GeeksforGeeks
geeksforgeeks.org › check-if-string-contains-substring-in-python
Check if String Contains Substring in Python - GeeksforGeeks
July 20, 2024 - ... In Python, you can check python substring in string is present using an if-else statement. The if-else statement allows you to conditionally execute different blocks of code based on whether the condition is true or false.
🌐
Quora
quora.com › How-do-I-check-if-a-string-contains-multiple-values-in-Python
How to check if a string contains multiple values in Python - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
AskPython
askpython.com › python › string › check-string-contains-substring-python
How to Check if a Python String Contains a Substring? - AskPython
May 27, 2023 - ... Now, let’s examine each of them separately, along with their respective syntax and examples. The find() method is used to check whether a string contains a particular substring or not.
🌐
Initial Commit
initialcommit.com › blog › python-string-contains
Check If Python String Contains Substring - Initial Commit
April 8, 2021 - The quickest way to determine whether or not a Python string contains a substring is to use the in operator. The result will be a boolean value telling you whether or not the substring is "in" the parent string.
🌐
GoLinuxCloud
golinuxcloud.com › home › programming › python › check if string contains substring in python
Check if String Contains Substring in Python: in, find(), index(), count(), and Regex
January 9, 2024 - Learn how to check if a string contains a substring in Python using the in operator, find(), index(), count(), and regex. See case-sensitive, case-insensitive, multiple substring, whole-word, and pattern matching examples.