Try this test:

any(substring in string for substring in substring_list)

It will return True if any of the substrings in substring_list is contained in string.

Note that there is a Python analogue of Marc Gravell's answer in the linked question:

from itertools import imap
any(imap(string.__contains__, substring_list)) 

In Python 3, you can use map directly instead:

any(map(string.__contains__, substring_list))

Probably the above version using a generator expression is more clear though.

Answer from Sven Marnach on Stack Overflow
๐ŸŒ
Python Examples
pythonexamples.org โ€บ python-check-if-string-contains-substring-from-list
Python - Check if String contains Substring from List
source_string = 'a b c d e f' list_of_strings = ['k', 'm', 'e' ] for substring in list_of_strings: if substring in source_string: print('String contains substring from list.') break
Discussions

python - How to check if a string is a substring of items in a list of strings - Stack Overflow
How do I search for items that contain the string 'abc' in the following list? xs = ['abc-123', 'def-456', 'ghi-789', 'abc-456'] The following checks if 'abc' is in the list, but does not detect '... 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
How to detect if a string contains a substring of a list (or dictionary)
You are currently checking whether z is a substring of any element of my_list. I think you want to check whether any element of my_list is a substring of z (also, the if is a little redundant, since any already gives a boolean value): def chek(z): return any(s in z for s in my_list) Might also be worth using lower on z before the check to ignore differences in capitalisation if you aren't already doing that (and assuming the elements in my_list are all lower-case). More on reddit.com
๐ŸŒ r/learnpython
5
22
July 13, 2021
python - Check if substring is in a list of strings? - Stack Overflow
I have found some answers to this question before, but they seem to be obsolete for the current Python versions (or at least they don't work for me). I want to check if a substring is contained in a More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
EyeHunts
tutorial.eyehunts.com โ€บ home โ€บ python check if string contains substring from list | example code
Python check if string contains substring from list | Example code
April 20, 2022 - Use any() function to check if a list contains a substring in Python. The any(iterable) with iterable as a for-loop that checks if any element in the list contains the substring and returns the Boolean value.
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ python โ€บ wzo2s8ib โ€บ python-string-contains-example
How to check if a string contains a substring in Python?
December 20, 2022 - To check if a Python string contains the desired substring, you can use the "in" operator or the string.find() method.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-test-if-string-contains-element-from-list
Python - Test if string contains element from list - GeeksforGeeks
July 11, 2025 - The re.compile() function compiles the pattern for faster matching and search checks for its presence in the string. This method is less efficient for simple substring checks due to overhead from compiling patterns.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how to check if any element in a list contains a substring
r/learnpython on Reddit: How to check if any element in a list contains a substring
October 28, 2019 -

Say I have a list of strings like: ["Hey dude", "Hey bro", "Sup dude", "Hey bud"]

How do I check if *any* of those strings in the list contain the word "Sup"?Alternatively, in my case, I could also check if *all* of the strings contain "Hey" , which I also don't know how to do.

(Sorry, I'm new to Python)

Edit: Thank you so much for all the help, guys <3

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-finding-strings-with-given-substring-in-list
Finding Strings with Given Substring in List - Python - GeeksforGeeks
July 11, 2025 - a = ['GeeksforGeeks', 'Geeky', 'Computers', 'Algorithms'] b = 'Geek' # Substring res = [i for i in a if b in i] print(res) ... Explanation: list comprehension iterate through a, adding strings that contain the substring b to the list res.
Find elsewhere
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how to detect if a string contains a substring of a list (or dictionary)
How to detect if a string contains a substring of a list (or dictionary) : r/learnpython
July 13, 2021 - import re def check(chat_message_string): for banned_word in my_list: if re.findall(banned_word, chat_message_string, re.I): return(True) return(False) ... Fixed formatting. Hello, CloudNative13: code blocks using triple backticks (```) don't work on all versions of Reddit! Some users see this / this instead. To fix this, indent every line with 4 spaces instead. ... You can opt out by replying with backtickopt6 to this comment. ... Help me confirm my understanding of the is operator... ... Built a Python static analyzer that draws your call graph and marks values that go nowhere looking for holes in the concept
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ python-check-if-string-contains-element-from-list
Check if a String contains an Element from a List in Python | bobbyhadz
Copied!my_list = ['BOBBY', 'HADZ', 'COM'] substring = 'z' result = any(substring.lower() in word.lower() for word in my_list) print(result) # ๐Ÿ‘‰๏ธ True if any(substring.lower() in word.lower() for word in my_list): # ๐Ÿ‘‡๏ธ this runs print('The substring is contained in at least one of the list items') else: print('The substring is NOT contained in any of the list items') The str.lower method returns a copy of the string with all the cased characters converted to lowercase. The method doesn't change the original string, it returns a new string. Strings are immutable in Python.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ python-check-if-string-contains-substring
Python: Check if String Contains Substring
June 20, 2023 - To check if a string contains a substring in Python using the in operator, we simply invoke it on the superstring: fullstring = "StackAbuse" substring = "tack" if substring in fullstring: print("Found!") else: print("Not found!") This operator is shorthand for calling an object's __contains__ ...
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ 5 best ways to check if a python string contains an element from a list
5 Best Ways to Check if a Python String Contains an Element from a List - Be on the Right Side of Change
February 26, 2024 - If an element is found, the function immediately returns True; otherwise, after checking all elements, it returns False. List comprehension combined with the any() function provides a compact, Pythonic way to achieve the goal.
๐ŸŒ
Codecademy
codecademy.com โ€บ article โ€บ how-to-check-if-a-string-contains-a-substring-in-python
How to Check if a String Contains a Substring in Python | Codecademy
Since the substring is present in the string and it starts from index 17, the code produces this output: ... Letโ€™s move on to the next method on the list, which is the Python .contains() method.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ bytes โ€บ check-if-a-string-contains-an-element-from-a-list-in-python
Check if a String Contains an Element from a List in Python
October 6, 2023 - Hello is in the string Python is not in the string World is in the string ยท List comprehension is a concise way to create lists based on existing lists. It can also be used to perform operations on each element in a list. Link: For more information on list comprehension, check out our more comprehensive guide: ... In our case, we can use list comprehension to create a new list that contains the elements from my_list that are found in my_string.
๐ŸŒ
Devsheet
devsheet.com โ€บ check-if-a-substring-exists-in-a-list-of-strings-python
Check if a substring exists in a list of strings Python - Devsheet
Then, we use the any() function to check if any of the substrings in the list contain the string "pp". If any of the substrings do contain "pp", the substr_exist variable will be set to True, and the code will print "Substring exist".
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ check-if-string-contains-substring-in-python
Check if String Contains Substring in Python - GeeksforGeeks
December 20, 2025 - The index() method works similarly to find() but raises a ValueError if the substring does not exist in the string. It is useful when you need the exact position of the substring and want an explicit error if itโ€™s missing.
๐ŸŒ
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 - Using theโ€™ inโ€™ operator is one of Pythonโ€™s simplest and most commonly used methods to check if a string contains a substring. This operator returns True if the substring is found in the string and False otherwise.