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
🌐
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
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
python - Efficient multiple substrings search - Software Engineering Stack Exchange
I have many substrings(2-5 words each) which I would like to search in some text of about 40-50 words length. What is the most efficient way to flag matching substrings. Currently I am simply usin... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.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
🌐
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 - The any() function will short-circuit returning True if at least one string is contained in the other string. You can use the assignment expression syntax if you need to get the value that is 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 ...
🌐
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
Above example return "one" because the word "one" is the starting word and exists in the myList also. Similarly to check if all the strings from the list are found, use "all" instead of "any" . Above example return False because "six" is not in the string. Each of these methods allows you to check for the existence of multiple substrings 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.")
🌐
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.")
🌐
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.
🌐
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.
🌐
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.
🌐
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.
🌐
Udemy
blog.udemy.com › home › it & development › software development › the many ways to check if a python string contains a substring
Ways to Check if a Python String Contains a Substring - Udemy Blog
April 14, 2026 - You can also use the contains method of the Python str class directly. Here’s how we would do that: The first argument is the string you are searching, and the second is the substring you are looking for.